views:

40

answers:

3

I have a large div housing my background image. Generally, it will be centered with the sides going off the screen. Because it is background, I don't want scrollbars to show up on the browser- is there a solution here?

Thanks

EDIT: Let me clarify based on the answers:

I have a large image that extends beyond the browser's boundaries, but that I need to assign to a div background or img instead of the body background because I'm manipulating it w jquery, etc.

  • I know it is not possible for a div's background image to extend beyond its borders.
  • I also can't use an img or nested div with overflow:hidden because that would hide the overflow, when all I want is for it to not trigger scrolls, i.e. be ignored physically by layout engine but still be shown visually, just like an overflowing body background would.
+1  A: 

set the div to overflow: hidden

bemace
This won't work- see my edits
Yarin
A: 

Set these attrs in css class:

overflow: hidden;
max-height:300px;

Change 300px to your desire length.

Sag-e-Attar Junaid Atari
This won't work- see my edits
Yarin
A: 

Based on the additional info I came up with this example. The image is the background of a div that fills the whole visible area and pretty much acts just like it's the body's background image (tested in firefox). You could even scroll around the image by modifying the background-position attribute.

<html>
<head>
<style>
#test {
    position: fixed;
    left: 0px;
    right: 0px;
    top: 0px;
    bottom: 0px;
    background-image: url('http://farm5.static.flickr.com/4121/4805074237_6cf5880f75_o.jpg');
    background-position: 50% 50%;
    overflow: none;
    z-index: -1;
}
</style>
</head>
<body>
<div id="test">
</div>

Here's some other stuff in the body of the page.

<div>
and some stuff in a div in the body of the page.
</div>

</body>
</html>
bemace