0

The suggested solution to the problem of visible scrollbars does not work in the below scenario :

JSFIDDLe

CSS:

#hider {
    position:absolute;
    top: 0;
    left:0;
    height: 400px;
    width: 200px;
    background-color: green;
    overflow: hidden;
}

#scroller {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    padding-right: 20px;
    padding-bottom: 20px;
    overflow: auto;
}

#content {
    float: left;
    height: auto;
    width: auto;
}

HTML:

<div id="hider">
    <div id="scroller">
        <div id="content">
            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
            <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        </div>
    </div>
</div>

The problem I'm having is that the width of <div id="content"></div> cannot be known beforehand in my case, that's why I need to set it to auto.

In that case, the scrollbars are still hidden and the scrolling still works but there is one small "glitch" :

If you scroll all the way to the right, you'll notice that the last bit of <div id="content"></div> is cut off.

More specifically, the width of the part of <div id="content"></div> that is hidden on the right is equal to the width of the right padding applied to <div id="scroller"></div>. This is very weird.

Why is that and how do I work around that?

Thanks in advance for any help!

Community
  • 1
  • 1
Kawd
  • 4,122
  • 10
  • 37
  • 68

1 Answers1

1

Giving padding-right to #content class seems to solve the problem.

#content {
    padding-right: 10px; /* increase or decrease */
    /* other styles */
}

Working Fiddle

Mr_Green
  • 40,727
  • 45
  • 159
  • 271
  • Actually, a padding-right of around 30px seems to do the trick so that's great Mr_Green thanks a lot! :-) – Kawd Sep 28 '14 at 16:31