Element height: 100%

Discuss building things with or for the Mozilla Platform.
Post Reply
kremik
Posts: 1
Joined: May 28th, 2003, 11:11 pm
Location: Czech Republic

Element height: 100%

Post by kremik »

I wondered how to center any element horizontaly (ie. DIV). When I do this in CSS, it works in IE but not in Mozilla. I don't know how to set height to 100%.

.myElement {
width: 100%;
height: 100%;
text-align: center;
vertical-align: middle;
}

<body>
<div class="myElement">
someText
</div>
</body>
Sander
Posts: 634
Joined: November 5th, 2002, 5:35 am
Location: The Netherlands, when not travelling

Post by Sander »

margin-left: auto;
margin-right: auto;
for centering blocks.

set a height: 100% on the body to get the element to take up the full height. (but then you'll need to set padding and margin on the body to 0 to prevent scrollbars, and then if you want margin / padding again you'll need to use the children for that.
(The DOM-Inspector, btw, is your friend. It would've told you that the body's height wasn't taking up the entire screen.)
Post Reply