I have an absolutely positioned element that is \"outside\" of the page, but I want browsers (I am using Firefox 3) not to display horizontal scrollbars. It seems that displ
This can in fact be done using straight CSS without having any restrictions on page width etc. It can be done by:
The content in your first div will stay properly aligned with the content of your second div, but any of its contents that go beyond the perimeter of the window will be truncated.
Here's a working example that keeps the image in a fixed position relative to the rest of the content, without using any JavaScript:
#widthfitter {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
overflow: hidden;
}
#contentWrapper {
width: 100%;
position: absolute;
text-align: center;
top: 0;
left: 0;
}
.content {
width: 600px;
position: relative;
text-align: left;
margin: auto;
}
Tested successfully on:
- IE 8.0.6001.18702IS
- Google Chrome 17.0.963.46 beta
- Opera 10.10
- Konqueror 4.7.4
- Safari 5.1.5
- Firefox 10.0
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip
ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi.