On a web page, how can i have a scroll bar just for a certain section?

空扰寡人 提交于 2019-12-04 17:38:24

You need a max-height and overflow-y on the interior elements, and you need to set sizes on the outer elements:

HTML

<div class="outer">
    <div class="inner">foo</div>
    <div class="inner">bar</div>
    <div class="inner">whatever</div>
</div>

CSS

.outer {
    border: 2px solid red;
    float:left;
    top:0;
    bottom:0;
    position:absolute;
}
.inner {
    max-height:100%;
    overflow-y:auto;
    border: 2px solid blue;
    width:30%;
    margin-right:2%;
    float:left;
}

Here's a working fiddle

body, html {height: 100%}

.what_wraps_your_span {overflow-y: scroll; max-height: 100%;}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!