Home > Enterprise >  Font size of inline element creates gaps in HTML
Font size of inline element creates gaps in HTML

Time:08-12

Notice the vertical gaps caused by a small font size. There's no padding or margin yet there's a gap and this is incredibly annoying. I'd like to remove all vertical gaps and I want to keep wrap line functionality, and the child elements should retain their original height.

.container {
  border: 1px solid black;
}

.sub-container {
  border: 1px solid black;
  display: inline-flex;
  flex-direction: column;
}

.big-child {
  display: inline-block;
  font-size: 2em;
  border: 1px solid black;
}

.small-child {
  display: inline-block;
  font-size: 0.5em;
  border: 1px solid black;
}
<div >
  <div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div><div >
    <div >definition</div>
    <div >Word</div>
  </div>
</div>

CodePudding user response:

Try This

.container {
    display: flex;
    flex-wrap: wrap;
    border: 1px solid black;
}
  • Related