1

How would I use overflow-x: hidden on the body, but keep overflow-y: scroll?

I just put overflow: hidden on the body, and it worked (no scrolling on either axis). But when I try to specify an axis, like overflow-x: hidden, suddenly both axes become scrollable.

This should apply only to the body- I don't want to wrap anything inside a "wrapper" div.

This works, but cause both axes to not scroll:

body {
    overflow: hidden;
}

This causes both axes to scroll:

body {
    overflow-x: hidden;
}

The only thing inside the body is an absolutely positioned element.

2
  • Please show code, also a live example would be great Commented Jul 2, 2016 at 0:38
  • Your full code, for context Commented Jul 2, 2016 at 0:42

1 Answer 1

2

I've concluded that this is probably a bug in WebKit. According to this link:

https://css-tricks.com/findingfixing-unintended-body-overflow/

the author mentions this exact problem of specifying an axis inside body. It looks like you would have to use a wrapper div, as mentioned in other questions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.