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.
CSSWeb Languages and Standards

Avatar of undefined
Last Comment
Johan85

8/22/2022 - Mon
c-o-m-m-a-n-d-e-r

Mhh normally you can use overflow-x:hidden to the parent
c-o-m-m-a-n-d-e-r

Update : in your Example you have the Overflow-x use on html,body ....
ASKER CERTIFIED SOLUTION
Johan85

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
c-o-m-m-a-n-d-e-r

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

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
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/
Johan85

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