Forum Moderators: not2easy
<head>
<style type="text/css">#bgleft {
background: url(left_half_circle.gif) right top repeat-y;
}
#bgright {
background: url(right_half_circle.gif) left top repeat-y;
}
</style>
</head>
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="49%" id="bgleft"><img src="pixel.gif" alt="" height="1" width="1"></td>
<td width="2%" valign="top">
My 800px wide content goes here<br>
<img src="foo.gif" width="800" height="1000">
<td width="49%" id="bgright"><img src="pixel.gif" alt="" height="1" width="1"></td>
</tr>
</table>
</body>
</html>
For reference assume the left bg image if like this: <snip> and the right like this: <snip>
The code above creates a 800px center column with the half circle images on either side fixed, vertically repeating as the background. Horizontal scrollbars only appear if the width of the window is less than 802px.
How would I re-create the table using CSS positioned divs?
[edited by: Robin_reala at 11:10 am (utc) on Mar. 10, 2007]
HTML:
<body>
<div id="content">My content</div>
</body> CSS:
body {
background: url(my_image.png) repeat-y 50% 0;
}
#content {
width: 800px;
margin: 0 auto;
}
If my BG image is 1000px wide with 800px of white space in the middle and the viewable browser area is of an odd number then the image doesn't get centered properly.
It seems if I do as you say and instead of making the white space in the BG image 800px I make it 799px it would cover over the 1px glitch I mentioned above.
As long as the main container has a solid background to cover over the 1px of extra background sitting underneath it, it will work fine.
regards
#centeringContainer {
width: 860px;
margin-left: auto;
margin-right: auto;
}
#leftImage {
width: 860px;
background-image: url(?);
background-position: top left;
background-repeat: repeat-y;
}
#rightImage {
width: 860px;
background-image: url(?);
background-position: top right;
background-repeat: repeat-y;
}
#contentContainer {
width: 800px;
margin-left: 30px;
margin-right: 30px;
}
Notice 30px margin either side for contentContainer
<div id="centeringContainer">
<div id="leftImage">
<div id="rightImage">
<div id="contentContainer">
<p>This my content</p>
</div>
</div>
</div>
</div>
Should work, i use something similar for applying extensible (horiz and vert) rounded corners which uses at least 8 container divs :-s