由于滚动条,2 divs偏移

时间:2014-06-03 01:00:31

标签: javascript jquery html css

问题#1

尝试让2个div彼此对齐,

第一个div没有滚动条,但第二个有一个滚动条。滚动条导致第二个div偏离第一个div。

有没有办法对齐这两个div?

问题#2

为什么第二个div在有溢出时不滚动:y;滚动; ?


body, html {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    overflow:hidden;
}
.fixed-top-container {
    text-align:center;
    top:0px;
    height:100px;
    min-height:100px;
    max-height:100px;
    width:100%;
    display:inline-block;
    margin:0 auto;
    padding:0;
    background-color:rgba(0, 0, 0, 0.5);
}
.container {
    width:100%;
    height:100%;
    background-color:#F0F0F0;
    overflow-y:scroll;
}
.content {
    width: 800px;
    height:100%;
    margin:0 auto;
    background-color:#FFFFFF;
}

查看JSFiddle问题:http://jsfiddle.net/Aaeijh/qAh9g/1/

2 个答案:

答案 0 :(得分:0)

  

我们怎样才能让底部div滚动?

使用用户友好的<textarea>代替旧的<div>技术

<textarea rows="10" cols="50" class="container">
//your text here

</textarea>

JSFiddle

答案 1 :(得分:0)

删除overflow:hidden;overflow-y:scroll; ..