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 displaying a div that is positioned to the left (e.g. having "left: -20px") is okay, and no scrollbar is shown. However the same thing on the right ("right: -20px") always shows the scrollbar. Is it possible to hide the scrollbar, but to keep standard scrolling possible? I mean I only want to disable scrolling due to this absolute-positioned element, but to keep scrolling due to other elements (I know I can disable scrollbars completely, that's not what I want).
<!DOCTYPE html>
<html>
<body>
<div id="el1" style="position: absolute; top: 0; background-color: yellow; left: -20px;">
element
</div>
<div id="el2" style="position: absolute; top: 0; background-color: yellow; right: -20px;">
element
</div>
<h1>Hello</h1>
<p>world</p>
</body>
</html>
Not too sure if this would help but you can try changing the styling for the mentioned divs to this instead:
By setting the position as fixed instead, it "locks" the specified divs in place while the rest of the content is still scrollable. Of course this is assuming that it is in the instance that the rest of the content is stacked by the z-index to be on top of the defined divs.
Hope this helps.
Put the following style
I tested it on IE 8, FF and Chrome.
Add this to your CSS:
The overflow-x and -y styles are not recognized by IE. So if you're only concerned with Firefox 3, this will work fine. Otherwise, you can use some javascript:
What you have to do is to add a wrapper outside of your divs.
Here is the CSS: I call my class 'main_body_container'
Hope it helps :)
Update
Created a Pen for it, see it here
Yes, it is possible, on your html tag, type
style="overflow-x: hidden"
. That'll do the trick...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: