stylesheet height

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

I have a DIV which I want to automatically resize when the user resizes the
browser.

The width setting is easy - I want it to appear on the left hand side of the
page and take up 50% of the screen so I set width:50%.

The height is more tricky since I want to size it from it's rendered
Y-position (which is not 0) down to the bottom of the browser. Hence if the
user resizes downwards the DIV should expand itself to fit the height
available. Since its Y position is not 0, setting height:100% will not work.
So I really need something like height:-30px assuming my div starts at
Y-co-ordinate 30 - but I'm not using absolute positioning so this may vary!

Any suggestions ?
 
you need to write javascript that does the resize. catch the onresize event,
and calc the new height for the div. see the html dom documentation for
properties.

-- bruce (sqlwork.com)
 
You wouldn't like to tell me how would you ? Cannot get it to work ... I
know next to nothing about javascript so I'm probably doing something
stupid.
 
How about this - IE only
<style type="text/css">
#test{
position:absolute;
top:100px;
left:100px;
border:1px solid black;
width:100px;
height:expression(body.clientHeight-100 + "px");
}
</style>
</head>
<body>
<div id="test">
text
</div>

A lazy answer but might be good enough :-)

Cheers,
Jon
 
I could give that a try, thanks, but I really need something that will work
in most browsers - what makes this IE only ? body.clientHeight ?
I have found a method which does work but I'm using
document.body.offsetHeight - is this IE only too ?
 
Back
Top