我有一个固定在页面左侧的div,高度为100%。我在里面放置了超出左边div高度的内容。现在,我知道我可以添加overflow:auto以允许用户滚动该div中的内容,但我希望固定div内的内容随页面一起滚动。这是可能的只是CSS?制作固定内容滚动
感谢
的jsfiddle:http://jsfiddle.net/yZmu6/
HTML:
<div id="newsfeed-left">
<div class="green-square"></div>
<div class="blue-square"></div>
<div class="green-square"></div>
<div class="blue-square"></div>
<div class="green-square"></div>
<div class="blue-square"></div>
<div class="green-square"></div>
<div class="blue-square"></div>
<div class="green-square"></div>
</div>
CSS:
body {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
#newsfeed-left {
position: fixed;
float: left;
height: 100%;
width: 200px;
padding: 0px 10px 0px 10px;
border-right: 1px solid rgb(228, 228, 228);
}
.green-square {
margin: 10px 0px 0px 0px;
height: 200px;
width: 200px;
background-color: green;
}
.blue-square {
margin: 10px 0px 0px 0px;
height: 200px;
width: 200px;
background-color: blue;
}
没有,这是不可能的只是CSS。我建议你看看这个jQuery插件http://someweblog.com/hcsticky-jquery-floating-sticky-plugin/ –