#allcontents {
width: 1100px;
margin-left: auto;
margin-right: auto;
}
#sidebar {
padding: 10px;
position: sticky;
top: 20px;
left: 10px;
width: 150px;
border-right: 1px solid black;
float: left;
}
#main {
padding: 15px;
margin-left: 330px;
margin-bottom: 10px background-color:green;
width: 800px;
}
#footer {
background-color: gray;
clear: left;
}
<!doctype html>
<html>...
<body>
<div id="allcontents">
<div id="sidebar">
random contents
</div>
<div id="main">
</div>
<div id="footer">
</div>
</div>
</body>
</html>
当我向下滚动页面时,侧边栏内容与页脚重叠。
我该怎么解决?
1条答案
按热度按时间7gcisfzg1#
您可以考虑通过将
margin-bottom
添加到sidebar
来解决此问题,例如: