laradev
laradev

Reputation: 918

height: 100% not working for parent div with floated inner div

I have 3 floated div inside a parent div. first and last div has some fixed height (eg: 100px and 150px). For the second div, I have set the height to 100%. But the height of the second div is not increasing as the parent's height increases.

HTML

<div class="main">
    <div class="one">1</div>
    <div class="two"></div>
    <div class="three">3</div>
    <br style="clear: both" />
</div>

CSS

body, html {
    height: 100%;
}
.main {
    width: 500px;
}
.one, .two, .three {
    float: left;
    width: 150px;
    border: 1px solid #CCC;
    margin-left: 5px;
}
.one {
    height: 100px;
}
.two {
    height: 100%;
}
.three {
    height: 150px;
}

DEMO

Upvotes: 0

Views: 145

Answers (1)

pavel
pavel

Reputation: 27082

You have to set height to parent element (in this case .main) too, look

.main {height: 100%}

http://jsfiddle.net/p01trnj6/3/

Upvotes: 1

Related Questions