how can i have scrollbar when position is negative

2019-06-07 05:30发布

问题:

When position is positive, scrollbar work just fine. but when left is negative, scrollbar won't apear. how can i have scrollbar when element is on the left side or on the right side?

sample is here:

.container{
    position: relative;
    width: 350px;
    height: 250px;
    background: gray;
    overflow: scroll;
    margin: 10px auto;
}
.child {
    position: absolute;
    top : 200px;
    left: -50px;
    width: 150px;
    height: 150px;
    background: white;
    border: 1px solid blue;
}
<div class="container">
    <div class="child"></div>
</div>

回答1:

It seems like you cannot do that, because the browsers do not provide that feature.

This is my understanding after looking at the WebDriver spec http://w3c.github.io/webdriver/webdriver-spec.html

In the section titled 'Determining if an element is displayed'

there is a point that says "The User Agent must not allow negative scrolling"



标签: css scrollbar