关于css溢出的问题,麻烦解答下,谢谢
页面分成四个部分,头部、底部、中间的左边推荐、中间的右边推荐
但现在因为中间的左边推荐部分比较长,而造成溢出到底部了,请问如何解决?谢谢!~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head><title>谢谢解答</title><style>.container{width:98%;}.rightcontent{margin:5px 0 0 180px; background-color:#ececec;}.leftcontent{position: absolute; left: 10px; width: 170px; color: #564b47; margin: 0px; padding: 0px; overflow:auto;height:100%;}</style></head><body><div class="container">这是头部</div><div class="container"><div class="rightcontent">内容的右边</div><div class="leftcontent"><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div><div>左边的推荐列表</div></div></div><div class="container">这里是底部,看不到啊啊啊啊啊啊啊啊啊</div></body></html>.leftcontent{position: absolute; left: 10px; width: 170px; color: #564b47; margin: 0px; padding: 0px; overflow:auto;height:auto;}
[解决办法]
把.leftcontent中的positon属性值改成:relative;
改后如下:
.leftcontent{
position: relative;
left: 10px;
width: 170px;
color: #564b47;
margin: 0px;
padding: 0px;
overflow:auto;
height:100%;
}