bunner bob
01-27-2009, 05:57 PM
Howdy,
I'd like to be able to position a background image so that it overhangs its container (to the right side) but doesn't cause the browser to "see" the container as any wider than it is.
// HTML
<body>
<div id="container">
<div id="overhangThing"></div>
// rest of site content
</div>
</body>
// CSS
#container {
width: 600px;
margin: 0 auto;
position: relative;
}
#overhangThing {
width: 400px;
position: absolute;
top: 0;
left: 400px;
background: transparent url("images/400PixelWideImage.gif") 0 0 no-repeat;
}
Since #overhangThing is 400 wide and positioned at 400, it is telling the browser that it should be adjusting for 800px wide content. Thanks to the absolute positioning of #overhangThing, #content div stays centered but a horizontal scrollbar appears when the window is less than 800px wide. I want the overhang portion to behave as a background image, and not affect the way the browser perceives the content width.
Any suggestions?
I'd like to be able to position a background image so that it overhangs its container (to the right side) but doesn't cause the browser to "see" the container as any wider than it is.
// HTML
<body>
<div id="container">
<div id="overhangThing"></div>
// rest of site content
</div>
</body>
// CSS
#container {
width: 600px;
margin: 0 auto;
position: relative;
}
#overhangThing {
width: 400px;
position: absolute;
top: 0;
left: 400px;
background: transparent url("images/400PixelWideImage.gif") 0 0 no-repeat;
}
Since #overhangThing is 400 wide and positioned at 400, it is telling the browser that it should be adjusting for 800px wide content. Thanks to the absolute positioning of #overhangThing, #content div stays centered but a horizontal scrollbar appears when the window is less than 800px wide. I want the overhang portion to behave as a background image, and not affect the way the browser perceives the content width.
Any suggestions?