0

My problem is that i'm trying to get three entirely independent columns and with 'display: inline-block', my columns get side by side but starts under the biggest.

HTML, CSS:

.container > div {
 display: inline-block;
}
<body>
  <div class="container">
  <div>
    aaaaaaa<br>bbbbbb
  </div>
  <div>
    cccccc<br> ddddddd<br>eeeeeee
  </div>  
    <div id="end">
      ffffff
    </div>
  </div>
    
</body>

The problem is that the smallest line is aligned to the last line of the biggest div, as follows: The ffff is not right

Felipe Borges
  • 320
  • 3
  • 13

3 Answers3

1

When dealing with inline-level and table cell elements, the vertical-align property applies. The initial value of this property is baseline. That's what you're seeing. The text in each box is aligned to the baseline. Adjusting the vertical-align property to another value (such as top) solves the problem. https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
0

Found the solution, although i don't think it's the best way to do this:

.container > div {
   vertical-align: top;
}

:)

Felipe Borges
  • 320
  • 3
  • 13
0

You could add css property vertical-align: top, that way all content will start at the top of the div.

.container > div {
 display: inline-block;
vertical-align:top
}
<body>
  <div class="container">
  <div>
    aaaaaaa<br>bbbbbb
  </div>
  <div>
    cccccc<br> ddddddd<br>eeeeeee
  </div>  
    <div id="end">
      ffffff
    </div>
  </div>
    
</body>
Cristian Colorado
  • 2,022
  • 3
  • 19
  • 24