Hide "Horizontal" Scrollbar but still able to scroll

Here is how you do it, I have tested this in Chrome, IE, Firefox, Opera, Safari(Windows) and Edge

<h1>You can scroll with mouse wheel</h1>

<div id="box">
    <div id="content">
        <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
    </div>
</div>

h1{font-weight:bold;font-size:2em;} /* ignore only for header */
/* *********************** */
div#box{
    height:200px;
    width:300px;     
    overflow:hidden;
    border:1px solid black;
    padding: 10px;
}

div#content{
    height:200px;
    width:326px;
    /*
     * Uncomment to see scrollbar
    width:300px;
    */
    overflow:auto;
}

Here is a JSFiddle: http://jsfiddle.net/JoshMesser/VUSuZ/

Credits go to creator of the JsFiddle

EDIT:

For vertical it is just a matter of changing the height. What you are doing is you are just pushing the scroll bar outside of what user can see, so to them its not there, while in reality it is there hidden behind elements. Here is a JS Fiddle based on my last one. You will see I just forced p to be in single line to get horizontal scrolling and then increased the height to hide the scroll-able bar.

http://jsfiddle.net/VUSuZ/575/

Tags:

Css