R.Besseling
12-08-2006, 09:45 AM
Hello everyone,
I'm working on a community website at the moment and I have a problem with HTML/CSS. The height of content field of the website must resize with the browser without using 100%.
I used 'position: absolute' for this and it works fine with IE7, IE6 (with some JS in CSS), FireFox, Mozilla, Safari, Netscape and Opera 9. With Opera 7 and 8 it resizes with the resolution on the computer, but it doesn't when you make the browserwindow smaller. That's not a serios problem, because that will only affect a very small percentage of the visitors of my website (and I think it's a bug in Opera which I can't solve witout using percentages). The bigger problem is IE5 (3,2% of visitors in general). It doesn't display my webpage correct.
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<html>
<head>
<title>Bridge beheer - Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="language" http-equiv="language" content="nl">
<link rel="stylesheet" href="styles/main.css" type="text/css" />
</head>
<body>
<div id="main">Content
</div>
</body>
</html>
CSS
body
{
color: #000000;
font-size: 12px;
background: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif;
margin: 0px;
}
#main
{
width: 740px;
background-color: #FF0000;
position: absolute;
top: 0px;
bottom: 0px;
left: 50%;
margin-left: -370px;
}
* html #main
{
height: expression((parseInt( document.documentElement.clientHeight ))+'px');
}
Displaying correct with IE7 (http://www.cerus.nl/screen-ie7.gif)
Displaying incorrect with IE5 (http://www.cerus.nl/screen-ie5.gif)
As you can see I used the 'negative margin method' to center my main div, because 'margin: 0px auto' doesn't work with 'position: absolute'. I also used a CSS expression for IE6.
Does anyone know what I have to change in my code so that my website also displays in IE5 correct?
Thanks!
P.S. Sorry for the bad English, I am a proud Dutchie ;)
I'm working on a community website at the moment and I have a problem with HTML/CSS. The height of content field of the website must resize with the browser without using 100%.
I used 'position: absolute' for this and it works fine with IE7, IE6 (with some JS in CSS), FireFox, Mozilla, Safari, Netscape and Opera 9. With Opera 7 and 8 it resizes with the resolution on the computer, but it doesn't when you make the browserwindow smaller. That's not a serios problem, because that will only affect a very small percentage of the visitors of my website (and I think it's a bug in Opera which I can't solve witout using percentages). The bigger problem is IE5 (3,2% of visitors in general). It doesn't display my webpage correct.
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<html>
<head>
<title>Bridge beheer - Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="language" http-equiv="language" content="nl">
<link rel="stylesheet" href="styles/main.css" type="text/css" />
</head>
<body>
<div id="main">Content
</div>
</body>
</html>
CSS
body
{
color: #000000;
font-size: 12px;
background: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif;
margin: 0px;
}
#main
{
width: 740px;
background-color: #FF0000;
position: absolute;
top: 0px;
bottom: 0px;
left: 50%;
margin-left: -370px;
}
* html #main
{
height: expression((parseInt( document.documentElement.clientHeight ))+'px');
}
Displaying correct with IE7 (http://www.cerus.nl/screen-ie7.gif)
Displaying incorrect with IE5 (http://www.cerus.nl/screen-ie5.gif)
As you can see I used the 'negative margin method' to center my main div, because 'margin: 0px auto' doesn't work with 'position: absolute'. I also used a CSS expression for IE6.
Does anyone know what I have to change in my code so that my website also displays in IE5 correct?
Thanks!
P.S. Sorry for the bad English, I am a proud Dutchie ;)