tags:

views:

52

answers:

2

I have two floating divs, each is 50% wide, the problem I have is that I can't get them to stretch to the full height of the window. Essentially I want each div to have 50% width and 100% height (but it isn't working)

html

<section>
    <div></div>
</section>
<section>
    <div></div>
</section>

css

section {
    background: black;
    width: 50%; min-height: 100%; height: 100%;
    margin: 0;
    float: left;
}
section > div {
    height: 100%;
}
A: 

Assuming that when you talk about 100% height, you're referring to 100% of the view port, in order to use 100% height for an element like a div, you need to have it's container element set to 100% as well... most likely, your body/html tags aren't set to 100%, and that's the reason why wend you set 100% height to your two floating div doesn't seem to work!

Ex:

html, body { width:100%; height:100%; }
div#one { float:left; width:50%; height:100%; }
div#two { float:right; width:50%; height:100%; }

This is a sample CSS code, there's others ways to this with far less code...

Hope it helps!

Zuul
There's one drawback to this: in WebKit-based browsers, 50% of an uneven with will be rounded down, resulting in a 1px gap between the two divs when the width of the window is uneven (just try to resize Chrome's or Safari's window a few times).
Marcel Korpel
@Marcel Korpel, Its and odd scenery, but I've just learn something new ;) Tks!
Zuul
You're welcome. Oh my, I meant ‘width’, not ‘with’. :X
Marcel Korpel
A: 

I think this might help you..

http://www.alistapart.com/articles/fauxcolumns/

It indicates how you can have aligned columns :)

Prozaker