Link to home
Start Free TrialLog in
Avatar of Johan85
Johan85

asked on

How to prevent horizontal scrollbar?

When using negative left margin, or negative left positioning, no horizontal scrollbar appear in the browser window.

However, when you use negative right margin, or negative right positioning, a scrollbar does appear.

I've set up an example:
http://jsfiddle.net/PPmeS/

Does anybody know of a way to prevent the scrollbar for content that is pulled out on the right side. In my case it's just a decorative photo which should be cut off if the window is too small.

Thank you.
Avatar of c-o-m-m-a-n-d-e-r
c-o-m-m-a-n-d-e-r

Mhh normally you can use overflow-x:hidden to the parent
Update : in your Example you have the Overflow-x use on html,body ....
ASKER CERTIFIED SOLUTION
Avatar of Johan85
Johan85

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes thats right....but this Info wash´t given *smile*

If i think about that you can try with another wrapper around that with 100% width and overflow-x:hidden

Avatar of Johan85

ASKER

Oh well, my bad, I forgot to remove the overflow-x declaration on html,body at the top. No wonder the media query had no effect. It works now:

http://jsfiddle.net/PPmeS/5/
Avatar of Johan85

ASKER

When the scrollbar appears, it still allows to scroll beyond the content width, but all in all this is a workable solution.