How to increase div height depends on contents inside?

I have a nested divs, with most of them float:left; display:block;, like do:

<div class="container" style="display:block;">
    <div style="float:left; display:block; height:100px;">
    <div style="float:left; display:block; height:100px;">
</div>

I want the container to divgrow without setting the height. This is currently a flat line.
How to adjust the inner divs so that the container has a height?

TL DR : Currently, I can see 2 inside divfine, but the container is flat div(no height).
How do I give height?

+5
source share
2 answers

You have two options:

<div class="container" style="overflow:hidden">
    <div style="float:left; height:100px;">
    <div style="float:left; height:100px;">
</div>

or

<div class="container">
    <div style="float:left; height:100px;">
    <div style="float:left; height:100px;">
    <div style="clear:left">
</div>

, overflow:hidden . , , float, .

: , divs display:block. HTML 2 , block inline. block.

+9

overflow:hidden DIV.

+2

All Articles