Avatar of 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:

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

8/22/2022 - Mon

Mhh normally you can use overflow-x:hidden to the parent

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

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
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

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

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:


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