tags:

views:

236

answers:

6

I tried using

height: 100%

but this makes the div only as high as its contents - it just contains a single word of text.

How can I force the div to use the screen height instead?

A: 

You can get the width and height of the window using JavaScript and then use those values to set the height and width of the div, as needed.

Thomas Owens
A: 

maybe

min-height:100%;

what are you trying to do exactly? post some more info and we can help you more

Ryan
+5  A: 

You need the body and html elements to have 100% height as well.

Try the following CSS:

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

YourDivSelector {
    height: 100%;
}

The margin and padding must be set to 0 to prevent autoscroll in Firefox.

SLaks
That did the trick.
ipso facto
+1  A: 

You should set all the containers that contain the div to height:100% as well, including the body and html tags.

Andrew Johnson
This was what I needed but I gave SLaks the answer tag because his came before yours. Thanks!
ipso facto
+1  A: 

You also need to set html and body to height:100%;

 html,body{height:100%}
Emily
A: 

You can only meaningfully use height=100% if its containing element's height is definided. Its 100%, of what? no height if defined anywhere. You can use javascript to get the height of the current window (as previously mentioned), or specify a specific height of 800px or whatever value. :D

CrazyJugglerDrummer