Click to See Complete Forum and Search --> : [RESOLVED] Dynamically Sizing <divs>
Jforsyth
08-12-2008, 09:18 PM
Hi,
I would like to create a <div> on my page that changes size as the user changes the size of the window.
I have been able to get the width to change easy, but cannot get the height increase/decrease with the window.
How could I do this?
irf2k
08-12-2008, 10:45 PM
i'm a little new to CSS (well, proper CSS) but from what I know, the width of the div, unless specified, is 100% of the container that holds it...
so if your div is in not constrained by anything, the WIDTH will automatically expand as the width of the browser window expands
to have the height change dynamically, you'll probably need to use javascript to determine when the user changes the size of the window :P
im not experienced with javascript, but to get the width of the current document, you'd need to use document.body.offsetWidth (not sure how cross-browser compatible it is)
mb if you tell us what you want to accomplish. there may be an easier way?
Centauri
08-13-2008, 01:58 AM
If the height of html AND body are both set to 100%, they will be the size of the window, and if the div in question is a direct child of body, then its height can be specified as a percentage.
Jforsyth
08-13-2008, 02:23 AM
Thank you for the help. It appears to be scaling in both directions now :)