Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline-block expand height parent container

Tags:

html

css

I have 2 div elements side by side that are set as inline-block. They both reside within a containing div. I have set the right div to height 100% but because the height of the containing div is dynamic it won't expand. Does anyone know how to make the right hand div (coulmn) expand to the dynamic height of the containing div?

<div class="container">
<div class="left_column">Dynamic Content In Here</div>
<div class="right_column">Side bar to expand to the height of the containing div</div>
</div>

Thanks

Oliver

like image 477
ORStudios Avatar asked Dec 10 '11 14:12

ORStudios


People also ask

Can we change height of inline elements?

Inline element properties: The height of an inline element is the height of the content. The width of an inline element is the width of the content. The height and width of an inline element cannot be set in CSS. You cannot set the height and width of block-level elements in CSS.

How do inline-block elements add up to 100 width?

To do this, you simply need to add display: flex to the parent container and flex-grow: 1 to the divs (as opposed to defining a width). With the flexbox styles applied, we can have three inline divs of equal width – just as we can with the inline-block solutions.

Do inline elements take up the entire width of their container?

Note: An inline element does not start on a new line and only takes up as much width as necessary.

What is the difference between block inline inline-block and box sizing?

The display: inline-block Value Compared to display: inline , the major difference is that display: inline-block allows to set a width and height on the element. Also, with display: inline-block , the top and bottom margins/paddings are respected, but with display: inline they are not.


2 Answers

After having some issues with the same problem, the simplest solution is, in my opinion, to use table-cell as the display property. It works perfectly fine!

like image 176
Thomas Avatar answered Oct 03 '22 18:10

Thomas


I think you search something like this:

.container {
    min-height: 700px;
}

.right_column {
    min-height: inherit;
}

Also see this jsfiddle.

like image 23
scessor Avatar answered Oct 03 '22 18:10

scessor