Eddy999999
12-14-2006, 05:51 PM
I'm kind of a newbie at CSS, and I'm trying to make a layout for my game I'm working on in PHP using CSS instead of tables. The basic layout is a main content div in the center, with top, left, right, and bottom divs around it. Everything looks perfect in Firefox, but not so much in IE.
It looks to me like IE is not calculating the widths correctly for the divs. I took a screenshot, calculated what the widths of the divs should be, and measured it out in PSP, and they don't match up with what they are supposed to be. Heres the source code:
site.css:
body
{
color: #404040;
text-align: center;
background-image: url('Images/pageBG.jpg');
}
#headerContent
{
position: absolute;
background-image: url('Images/menuBG.jpg');
left:2%;
top:2%;
width: 96%;
height:11%;
}
#leftContent
{
background-image: url('Images/menuBG.jpg');
position: absolute;
left:2%;
top: 12%;
right:83%;
height: 86%;
width: 15%;
}
#mainContent
{
background-image: url('Images/contentBG.jpg');
position: absolute;
top:12%;
left:17%;
right:17%;
height: 71%;
width: 66%;
overflow: auto;
}
#rightContent
{
background-image: url('Images/menuBG.jpg');
position: absolute;
top:12%;
left:83%;
height:71%;
width:15%;
margin-left:0%;
}
#bottomContent
{
background-image: url('Images/menuBG.jpg');
position: absolute;
top:83%;
left:17%;
width:81%;
height:15%;
margin-top:0%;
margin-left:0%;
}
#headerBackground
{
background-image: url('Images/specialBG.jpg');
border: 3px outset #000000;
width: 75%;
margin: auto auto auto auto;
}
#links
{
background-image: url('Images/specialBG.jpg');
width: 75%;
height: 50%;
margin: 25% auto 25% auto;
border: 3px outset #000000;
}
#cornerTL
{
background-image: url('Images/cornerTL.jpg');
background-repeat: none;
position:absolute;
width: 25px;
height: 25px;
top:2%;
left:2%;
}
#cornerTR
{
background-image: url('Images/cornerTR.jpg');
background-repeat: none;
position:absolute;
width: 25px;
height: 25px;
top:2%;
left:98%;
margin-left:-25px;
}
#cornerBL
{
background-image: url('Images/cornerBL.jpg');
background-repeat: no-repeat;
position: absolute;
width:25px;
height:25px;
top:98%;
left:2%;
margin-top:-25px;
}
#cornerBR
{
background-image: url('Images/cornerBR.jpg');
background-repeat: no-repeat;
position: absolute;
width:25px;
height:25px;
top:98%;
left:98%;
margin-top:-25px;
margin-left:-25px;
}
span.pop
{
color:c0c0c0;
}
h1, h2, h3, h4, h5, h6
{
font-family: "algerian";
color: #c00000;
}
a
{
color: #808080;
text-decoration: none;
font-weight: bold;
}
a span
{
display:none;
}
a:hover span
{
display:block;
position:absolute;
top:0%;
left:80%;
width:100%;
background-color: #c0c0c0;
color: #404040;
border: 3px outset #000000;
font-size:75%;
z-index:1;
}
#pop
{
margin:0px;
position:relative;
}
table
{
margin-left: auto;
margin-right: auto;
}
layoutTest.html (A page I created just to test the layout)
<html>
<head>
<title>Test Page</title>
<link href="site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="headerContent">
<div id="headerBackground"><h1 style="margin-top:0px; margin-bottom:0px; color: #c00000;">Layout Test Page</h1></div>
</div>
<div id="leftContent">
<div id="links">
<h2 style="color: #c00000;">Menu</h2>
<font size=4>
<div id="pop"><a href="test1.html">Test Link 1<span>This is the first Test Link</span></a></div>
<div id="pop"><a href="test2.html">Test Link 2<span>This is the second Test Link</span></a></div>
<div id="pop"><a href="test3.html">Test Link 3<span>This is the third Test Link</span></a></div>
</div>
</font>
</div>
<div id="rightContent">
<p style="color:#800000">This is the right content</p>
</div>
<div id="bottomContent">
<p style="color:#800000">This is the bottom content</p>
</div>
<div id="mainContent"><div id="mainBorder">
<p>This is the main content</p>
</div></div>
<div id="cornerTL"></div><div id="cornerTR"></div><div id="cornerBL"></div><div id="cornerBR"></div>
</body>
</html>
If you want to see what it looks like, go here:
http://mikwaz.freehostia.com/fg2/layoutTest.html
What really confuses me is why the heights and left and top coordinates are calculated correctly, but the widths are not, even though they all use percentages. Someone please help me figure out what is wrong. I have been trying to figure this out for a while, and google isn't seeming to help :(
It looks to me like IE is not calculating the widths correctly for the divs. I took a screenshot, calculated what the widths of the divs should be, and measured it out in PSP, and they don't match up with what they are supposed to be. Heres the source code:
site.css:
body
{
color: #404040;
text-align: center;
background-image: url('Images/pageBG.jpg');
}
#headerContent
{
position: absolute;
background-image: url('Images/menuBG.jpg');
left:2%;
top:2%;
width: 96%;
height:11%;
}
#leftContent
{
background-image: url('Images/menuBG.jpg');
position: absolute;
left:2%;
top: 12%;
right:83%;
height: 86%;
width: 15%;
}
#mainContent
{
background-image: url('Images/contentBG.jpg');
position: absolute;
top:12%;
left:17%;
right:17%;
height: 71%;
width: 66%;
overflow: auto;
}
#rightContent
{
background-image: url('Images/menuBG.jpg');
position: absolute;
top:12%;
left:83%;
height:71%;
width:15%;
margin-left:0%;
}
#bottomContent
{
background-image: url('Images/menuBG.jpg');
position: absolute;
top:83%;
left:17%;
width:81%;
height:15%;
margin-top:0%;
margin-left:0%;
}
#headerBackground
{
background-image: url('Images/specialBG.jpg');
border: 3px outset #000000;
width: 75%;
margin: auto auto auto auto;
}
#links
{
background-image: url('Images/specialBG.jpg');
width: 75%;
height: 50%;
margin: 25% auto 25% auto;
border: 3px outset #000000;
}
#cornerTL
{
background-image: url('Images/cornerTL.jpg');
background-repeat: none;
position:absolute;
width: 25px;
height: 25px;
top:2%;
left:2%;
}
#cornerTR
{
background-image: url('Images/cornerTR.jpg');
background-repeat: none;
position:absolute;
width: 25px;
height: 25px;
top:2%;
left:98%;
margin-left:-25px;
}
#cornerBL
{
background-image: url('Images/cornerBL.jpg');
background-repeat: no-repeat;
position: absolute;
width:25px;
height:25px;
top:98%;
left:2%;
margin-top:-25px;
}
#cornerBR
{
background-image: url('Images/cornerBR.jpg');
background-repeat: no-repeat;
position: absolute;
width:25px;
height:25px;
top:98%;
left:98%;
margin-top:-25px;
margin-left:-25px;
}
span.pop
{
color:c0c0c0;
}
h1, h2, h3, h4, h5, h6
{
font-family: "algerian";
color: #c00000;
}
a
{
color: #808080;
text-decoration: none;
font-weight: bold;
}
a span
{
display:none;
}
a:hover span
{
display:block;
position:absolute;
top:0%;
left:80%;
width:100%;
background-color: #c0c0c0;
color: #404040;
border: 3px outset #000000;
font-size:75%;
z-index:1;
}
#pop
{
margin:0px;
position:relative;
}
table
{
margin-left: auto;
margin-right: auto;
}
layoutTest.html (A page I created just to test the layout)
<html>
<head>
<title>Test Page</title>
<link href="site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="headerContent">
<div id="headerBackground"><h1 style="margin-top:0px; margin-bottom:0px; color: #c00000;">Layout Test Page</h1></div>
</div>
<div id="leftContent">
<div id="links">
<h2 style="color: #c00000;">Menu</h2>
<font size=4>
<div id="pop"><a href="test1.html">Test Link 1<span>This is the first Test Link</span></a></div>
<div id="pop"><a href="test2.html">Test Link 2<span>This is the second Test Link</span></a></div>
<div id="pop"><a href="test3.html">Test Link 3<span>This is the third Test Link</span></a></div>
</div>
</font>
</div>
<div id="rightContent">
<p style="color:#800000">This is the right content</p>
</div>
<div id="bottomContent">
<p style="color:#800000">This is the bottom content</p>
</div>
<div id="mainContent"><div id="mainBorder">
<p>This is the main content</p>
</div></div>
<div id="cornerTL"></div><div id="cornerTR"></div><div id="cornerBL"></div><div id="cornerBR"></div>
</body>
</html>
If you want to see what it looks like, go here:
http://mikwaz.freehostia.com/fg2/layoutTest.html
What really confuses me is why the heights and left and top coordinates are calculated correctly, but the widths are not, even though they all use percentages. Someone please help me figure out what is wrong. I have been trying to figure this out for a while, and google isn't seeming to help :(