如何使用CSS使列独立滚动

  • 本文关键字:独立 滚动 何使用 CSS css
  • 更新时间 :
  • 英文 :


这是我在这里的第一个帖子(我对这一切都很陌生),但我希望我问得正确。

我正在为我的硕士论文创建一个网页,我需要有三个平行的文本列,将彼此独立滚动,很像这个模板

我似乎无法从这个模板中获得CSS在我的网站上工作,我想知道我做错了什么,或者是否有更好的方法来实现这种效果。

谢谢你的帮助!

这是我网站的CSS

    body {
    padding:0;          
    width:100%;
    height: 100%;
    max-height: 100%;
    overflow; hidden;
    margin: 0;
    border: 0;
    background:#FFFFFF;     
    }
#title { 
    margin-bottom: 5px;
    background: #fff;
    width:100%
    z-index: 20;
    width: 100%;
    padding-top: 30px;
    }
#title h1 {
    font-family: Sorts Mill Goudy, Garamound, serif;
    font-size: 50px;
    text-align: center;
    font-weight: 100;
    color: 696969;
    line-height: 1px;
    letter-spacing: 10px;
    margin-top: 20px;   
    }

#title h2 {
    font-size: 16px;
    font-family: Sorts Mill Goudy, serif;
    text-align: center;
    font-weight: 100;
    color: #999;
    line-height: 20px;
    letter-spacing: 0px;
    }

#title ul {text-align:center; 
    padding-left, padding-right: 10px;
    padding-top: 30px;
    }
#title ul li {
    display:inline;
    font-family: "gill sans mt", "sans-serif";
    text-align: center;
    list-style:none;
    margin-left:0px;
    padding-left: 30px;
    padding-right: 30px;
    }
#title p{
    font-family: Sorts Mill Goudy Italic, Garamound, serif;
    size: 14px;
    font-weight: 300;
    background: #eee;
    padding: 10px;
    margin-left: 80px;
    margin-right: 80px;
    margin-top: 20px;
    margin-bottom: 15px;
    text-decoration: none;
    color: #000;
    }

#title a {
    color:#000;
    text-decoration: none;
    text-decoration: underline;
    }
#title a:hover {
    color: #A9A9A9;
    text-decoration: underline;
    }
/*  column settings */
#allcol {
    position: relative;
    }
#allcol h4{
    text-align: center;
    }
#col1 {
        font-family: Sorts Mill Goudy, Garamound, serif;
        text-align: left;
        float:left;
        background:#DCDCDC;
        padding-bottom:10px;
        padding-top: 10px;
        padding-left:1.5%;
        padding-right:1.5%;
        margin-left: 0px;
        width:30%;
        overflow: scroll;
        }
#col2 {     font-family: Sorts Mill Goudy, Garamound, serif;
        text-align: left;
        background: #fff;
        float:left;
        padding-bottom:10px;
        padding-top: 10px;
        padding-left:1.5%;
        padding-right:1.5%;
        width:30%;
        overflow: scroll;
        }
#col3 { font-family: Sorts Mill Goudy, Garamound, serif;
        text-align: left;
        float:left;
        background:#DCDCDC;
        padding-left:1.5%;
        padding-right:1.5%;
        padding-bottom:10px;
        padding-top: 10px;
        width:30%;
        overflow: scroll;
        }
#footer {
    clear:both;
    float:left;
    width:100%;
    border-top:1px solid #000;
    }

http://jsfiddle.net/78PrJ/

下面是一个工作示例。如前所述,您必须设置div height .

添加这个CSS: #col1, #col2, #col3{ height: 500px; }你已经使用overflow: scroll,所以滚动条将出现,

overflow:scroll仅在px中指定高度时有效。如果你在%age中指定高度,它将不起作用。

最新更新