Forum Moderators: not2easy

Message Too Old, No Replies

min-height issue.

         

prezet

11:14 am on Jun 27, 2006 (gmt 0)

10+ Year Member



Hi,

Can anyone enlighten me on why something happens? I'm using the following code:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
/* resets all elements */
html, body, ul, ol, li, p,
h1, h2, h3, h4, h5, h6,
form, fieldset, a, img, hr, blockquote {
margin: 0px;
padding: 0px;
border: none;
}
html, body {
height: 100%;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 62.5%;
line-height: 1.3em;
}
#container {
height: 50%;
}
#content {
min-height: 100%;
margin-bottom: -30px;
background-color:#00CC99;
}
* html #content { /* star hack for explorer only */
height: 100%;
}
#footerSpacer {
height: 40px;
}
#footer {
height: 30px;
background-color: #009999;
position: relative;
}
</style>
</head>

<body>

<div id="container">
<div id="content">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin congue odio eget turpis. Donec sollicitudin, pede ac sodales adipiscing, nulla erat consequat erat, nec ultricies ipsum urna non dolor. Sed ut erat. In hac habitasse platea dictumst. In leo. Fusce consectetuer mauris nec sapien. Pellentesque dignissim ornare elit. Vivamus urna nibh, feugiat quis, mattis nec, feugiat eu, nibh. Phasellus vitae leo. Nam imperdiet tellus et magna. Maecenas nisi.</p>
<p>Nulla commodo dolor at quam. Curabitur sollicitudin est eu libero. Ut vel diam. Sed iaculis. Aliquam eget sapien non nisl pharetra tincidunt. Nunc risus orci, congue ac, tempor eu, congue eget, lorem. Nulla luctus pretium augue. Vivamus dictum. Fusce laoreet velit sed mi. Nulla eget sapien. Donec rhoncus blandit lorem. Aliquam quis arcu ut ipsum consectetuer semper. Etiam eros quam, pulvinar nec, commodo at, consectetuer et, ligula.</p>
<div id="footerSpacer"></div>
</div>
<p id="footer">This is the footer</p>
</div>

</body>
</html>

Now, this works fine, but if I change the value of the container from:


#container {
height: 50%;
}

to:


#container {
min-height: 50%;
}

Why does the box collapse? Surely in this case min-height, and height should render the same, although the min-height should allow for expansion, right?

Am I missing something?

Thanks
Lee

4css

12:52 pm on Jun 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Prezet,
I dont' work with min height's etc.. but looking at your code:
html, body, ul, ol, li, p, 
h1, h2, h3, h4, h5, h6,
form, fieldset, a, img, hr, blockquote {
margin: 0px;
padding: 0px;
border: none;
}

You don't need to do your style in that form for the margins etc... There is a better way called global styling which will eliminate the need for you to type each element as you have it above. Just do this:

* {
margin: 0px;
padding: 0px;
border: 0px;
}

Once you do this, then you just apply your margins etc as you need them down the styles sheet.

another thing, a trick for the font sizing, and this takes care of your differences in sizing with the different browsers is to set your font to 100.01% like this:


html, body {
font-size: 100.01%;
}

Now once you do this, you can set your font sizing down the line to whatever you wish for it to be.

Also try to google to see if your question has been asked before, and make sure you validate your code.

gellydonut

8:45 pm on Jun 29, 2006 (gmt 0)

10+ Year Member



Here's a handy article detailing a cross-browser min-height hack - hope it helps out.

[greywyvern.com...]

doodlebee

4:13 am on Jun 30, 2006 (gmt 0)

10+ Year Member



Out of curiosity - which browser is it working in, and which is it not?