Scrolling in a div

2019-08-03 21:55发布

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?

enter image description here

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%;
}

标签: css html scroll
4条回答
别忘想泡老子
2楼-- · 2019-08-03 21:58

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

查看更多
Root(大扎)
3楼-- · 2019-08-03 21:59

Set the overflow property of that div.

overflow:scroll;
查看更多
别忘想泡老子
4楼-- · 2019-08-03 22:15

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

(Or alternatively to your #screen CSS declaration.)

查看更多
狗以群分
5楼-- · 2019-08-03 22:15
#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;
}
查看更多
登录 后发表回答