Scrolling in a div

2019-08-03 21:49发布

问题:

As you can see in the image below, I have a red div at the size of the "screen", what I want to is to make content scrollable in that area only. Is there a way to do that?

The whole pad's css:

#mainWindow{
    margin-left:auto;
    margin-right:auto;
    background-image:url("../images/mainWindow.png");
    background-size:100% 100%;
    height:100%;
    width:80%;
    padding:55px 60px 95px 65px;
    box-sizing:border-box;
    position: relative;
}

Screen's css:

#screen{
    border:1px solid red;
    width:100%;
    height:100%;
}

回答1:

Try adding overflow-y: scroll to your #mainWindow CSS declaration.

(Or alternatively to your #screen CSS declaration.)



回答2:

Set the overflow property of that div.

overflow:scroll;


回答3:

#divID {
    overflow: scroll;
}

...might do the trick. If you need the parent element to not scroll, you could maybe set it like:

#divID {
    overflow: hidden;
}


回答4:

The CSS tag you're looking for is 'overflow'



标签: css html scroll