简体   繁体   English

如何使此侧边栏可滚动?

[英]How do I make this sidebar scrollable?

How do I make this "sidebar" scrollable? 如何使“侧边栏”可滚动? I tried overflow: auto, but that didn't work. 我尝试了溢出:自动,但是没有用。

http://jsfiddle.net/kK2gD/ http://jsfiddle.net/kK2gD/

Correct the line ending for padding, and reduce the height of the sidebar. 校正行尾以进行填充,并减小边栏的高度。

#sidebar {
    float:left;
    width:330px;
    text-align:center;
    height:100px;
    background:#eee;
    padding:150px 5px;
    overflow: auto;
}

http://jsfiddle.net/wMq2E/ http://jsfiddle.net/wMq2E/

This will fix it: 这将解决它:

#sidebar {
    float:left;
    width:330px;
    text-align:center;
    height:200px;
    background:#eee;
    padding:150px 5px;
    overflow:scroll;
}

First, you were missing a ; 首先,您缺少一个; in padding . padding

Second, you should set overflow to scroll . 其次,您应该将overflow设置为scroll

This should work perfectly fine. 这应该工作得很好。 I found a typo in your css. 我在您的CSS中发现了一个错字。 At the end of 在......的最后

padding:150px 5px

the ; ; is missing. 不见了。 Should work with that. 应该可以。

padding:150px 5px;<-- you miss this coma
overflow:auto;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM