侧边栏超出包装范围?
Sidebar going outside of wrap?
这是代码,你可以很容易地看出哪里出了问题。
#wrap {
text-align: center;
height: auto;
margin: 0 auto;
width: 1024px;
background: #CCC;
}
#sidebar {
height: auto;
width: 300px;
padding: 20px;
margin-top: 60px;
padding-bottom: 100px;
border: outset;
float: right;
overflow: auto;
}
#content {
border: outset;
overflow: auto;
width: 500px;
height: auto;
padding: 20px;
margin-top: 60px;
padding-bottom: 100px;
clear: left;
}
<div id="wrap">
<div id="sidebar">Some text here</div>
<div id="content">Some text here</div>
</div>
我偷偷怀疑它与 float: right 有关,但没有它我无法让侧边栏保持在右侧。
我想让包裹展开到里面任何东西的高度,这就是我设置 height: auto 的原因,但它不起作用,请帮忙。
将此 css 属性添加到此 ID
#content{
float: left;
}
这是代码,你可以很容易地看出哪里出了问题。
#wrap {
text-align: center;
height: auto;
margin: 0 auto;
width: 1024px;
background: #CCC;
}
#sidebar {
height: auto;
width: 300px;
padding: 20px;
margin-top: 60px;
padding-bottom: 100px;
border: outset;
float: right;
overflow: auto;
}
#content {
border: outset;
overflow: auto;
width: 500px;
height: auto;
padding: 20px;
margin-top: 60px;
padding-bottom: 100px;
clear: left;
}
<div id="wrap">
<div id="sidebar">Some text here</div>
<div id="content">Some text here</div>
</div>
我偷偷怀疑它与 float: right 有关,但没有它我无法让侧边栏保持在右侧。
我想让包裹展开到里面任何东西的高度,这就是我设置 height: auto 的原因,但它不起作用,请帮忙。
将此 css 属性添加到此 ID
#content{
float: left;
}