Overflow-x hidden no body

3

I added Overflow-x: hidden in the body but it is not working.

overflow hidden disable scroll, or just hide the bar?

html, body{
  overflow-x: hidden;
  -webkit-overflow-x: hidden;
  
}
/* tentei das duas formas */
body{
  overflow-x: hidden;
}
    
asked by anonymous 13.05.2015 / 17:28

1 answer

2

To prevent scrolling, it is best not to let the elements exceed the maximum size of the parent element. Otherwise, the only way is with a bit of Javascript:

function wheel(e) {
    console.log(e);
    if ( e.wheelDeltaX !== 0 ) {
        e.preventDefault();
    }
};

function disable_scroll() {
    if ( window.addEventListener ) {
        window.addEventListener('DOMMouseScroll', wheel, false);
    }
    window.onmousewheel = document.onmousewheel = wheel;
};

disable_scroll();

See it working: JSFiddle

    
13.05.2015 / 18:48