Ultragames
12-13-2007, 06:52 AM
I have two objects positioned absolutely. They are both set to 50% left, but on uses a negative left margin to put it to the left of my container, and one uses a negative right margin to position it to the right of my container. Both are set to a z-index of 0.
Good: The one on the left does not affect the scroll bar, and is hidden in smaller windows.
Bad: The one on the right does affect the scroll bar, and is not hidden in smaller windows. I want both of the images to be hidden if the window is too small.
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="./css/style.css" media="screen" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WIP</title>
</head>
<body>
<div class="container">
Hello!
</div>
<img src="images/layout/bg_left.jpg" border="0" class="bg_left" />
<img src="images/layout/bg_right.jpg" border="0" class="bg_right" />
</body>
</html>
CSS:
body {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
.container {
width: 976px;
margin: 0px auto;
}
.bg_left {
width: 142px;
height: 576px;
z-index: 0;
position: absolute;
top: 312px; left: 50%;
margin-left: -630px; /* 1/2 container width + img width */
}
.bg_right {
width: 142px;
height: 576px;
z-index: 0;
position: absolute;
top: 312px; right: 50%;
margin-right: -630px; /* 1/2 container width + img width */
}
Good: The one on the left does not affect the scroll bar, and is hidden in smaller windows.
Bad: The one on the right does affect the scroll bar, and is not hidden in smaller windows. I want both of the images to be hidden if the window is too small.
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="./css/style.css" media="screen" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WIP</title>
</head>
<body>
<div class="container">
Hello!
</div>
<img src="images/layout/bg_left.jpg" border="0" class="bg_left" />
<img src="images/layout/bg_right.jpg" border="0" class="bg_right" />
</body>
</html>
CSS:
body {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
.container {
width: 976px;
margin: 0px auto;
}
.bg_left {
width: 142px;
height: 576px;
z-index: 0;
position: absolute;
top: 312px; left: 50%;
margin-left: -630px; /* 1/2 container width + img width */
}
.bg_right {
width: 142px;
height: 576px;
z-index: 0;
position: absolute;
top: 312px; right: 50%;
margin-right: -630px; /* 1/2 container width + img width */
}