2

How do I create a div that has a max width/height but instead of having scollbars have nothing yet still be able to scroll? (usually done via mouse wheel, selecting text and moving the mouse down or arrrows down)

I tried hidden but that doesn't let me scroll. The other options either doesn't allow it to have a max hight or puts scrollbars.

Here is a sample demo. I'd like to have no scroll bar but be able to see eof.

<div id=main>
    Text text text text text text text text...
    Text text text text text text text text...
    eof
</div>
#main {
    max-height: 400px;
    /*overflow: auto;*/
    overflow: hidden;
} 
7
  • Can you post your html? Commented Mar 9, 2013 at 18:40
  • @JackPettinger: I was trying to but for some reason SO isn't allowing me to edit my post. jsfiddle.net/dU3bB Commented Mar 9, 2013 at 18:40
  • 1
    @acidzombie24 Don't just paste links to jsfiddle. There's a reason for the message you saw. Commented Mar 9, 2013 at 18:48
  • @WesleyMurch: Yes but the code was meaningless. There was no reason to paste it. I only linked so people work on a demo and not start from scratch Commented Mar 9, 2013 at 18:51
  • I found this on SO click here Commented Mar 9, 2013 at 18:54

2 Answers 2

5

How about pushing the scrollbar into the hidden area ?

html,
body {
    padding: 0;
    margin: 0;
    overflow: hidden;
}
#container {
    position: absolute;
    left: 0;
    top: 0;
    right: -30px;
    bottom: 0;
    padding-right: 15px;
    overflow-y: scroll;
    max-height: 400px;
}

JSFiddle.

Example from SO - Hide the scrollbar but keep the ability to scroll with native feel.

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

Comments

2

For web kit engine supported browser(like Chrome) you can use this

#main ::-webkit-scrollbar 
{
    width: 0px;
}

but for other browser you need to something else.

Comments

Your Answer

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