stylesheet height

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 ?
 
B

bruce barker

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)
 
J

JezB

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.
 
J

Jon Spivey

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
 
J

JezB

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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top