Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove white spaces left after positioning div

I am trying to position a very basic div inline with some text.
When I move the div it leaves blank spaces that I can’t remove. Would you be kind to guide me with some css tricks for it?

.chord {
  color: orangered;
  font-weight: bold;
  display: inline;
  position: relative;
  top: -20px;
  left: 20px;
}
<br/> Empty
<div class="chord">Bm</div>spaces, what are we living for?<br/><br/> Abandoned
<div class="chord">G</div>places, I guess we know the score <br/>

Fiddle, in case you want to play with it.

https://jsfiddle.net/rondolfo/r3dphgsL/11/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I did search for an answer and I couldn’t find it, but I believe it is a very basic problem for someone that is proficient in css.

>Solution :

Use inline-flex instead of inline, set the width to 0. That will remove the space, but still show the chord text. You can also remove the left adjust and add a space before the div.

.chord{
    color: orangered;
    font-weight: bold;
    display: inline-flex;
    position: relative;
    top: -20px;
    width: 0px;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading