Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting the height of a div to some percent...

Status
Not open for further replies.

robi2

Programmer
Jan 19, 2003
62
IL
Hi, setting the height property of my div to some px value works fine, but when i set it to some sort of percent value it doesn't.

I mean:
<div style=&quot;height: 40%&quot;>Some text here</div>

so this should make my div be 40% of the height of my page...

I read that i need to set the parents elements height, so i set the body to 100% but this doesn't really seem to work...

Any suggestions?
 
Specifying the height of elements in percent is very tricky in Mozilla. If you want to stay on the safe side, it's usually better to avoid it.

You cannot add Height to the body tag, what I would suggest is use a form tag and give that a height, then you have the parentElement that you need.

<FORM style=&quot;height:480&quot;>

<DIV style=&quot;height:40%&quot;></DIV>

</FORM> MrGreed

&quot;did you just say Minkey?, yes that's what I said.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top