Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying vertical-align to two divs using inline-block

So I have some DIVs. The structure is this

    <div id="content">
        <div id="lcol">some content</div>
        <div id="lcol">some<br />content</div>
    </div>

And my problem is that the two divs are of different height. I'm using display:inline-block for 'lcol' while 'content' is just a regular div. The two lcol divs do indeed show up side by side, but they are anchored at the bottom of the div. I would like them to be aligned to the top of the div. I tried adding vertical-align:top to 'content' but nothing happened.

Any ideas?

JsFiddle: http://jsfiddle.net/qxe8h/1/

like image 264
Dalton Gore Avatar asked Aug 29 '12 09:08

Dalton Gore


People also ask

How do I vertically align two divs?

To align two <div> elements vertically in Bootstrap 3, you can try using the CSS Flexible Box Layout. In the example below, we display the needed row as a flex container box with the CSS display property and then, align the flex-items (columns) vertically with the align-items property.

How do you align inline block elements?

Inline block divs can be centered by applying text-align:center to their parent.

How do you vertically align a block in CSS?

To center both vertically and horizontally, use padding and text-align: center : I am vertically and horizontally centered.

How do you make two divs align next to each other?

With CSS properties, you can easily put two <div> next to each other in HTML. Use the CSS property float to achieve this. With that, add height:100px and set margin.


1 Answers

Give vertical-align:top to your inline-block elements. Write like this:

#lcol {vertical-align:top;}

Check this http://jsfiddle.net/qxe8h/2/

like image 158
sandeep Avatar answered Sep 17 '22 22:09

sandeep