【发布时间】:2016-04-08 14:52:15
【问题描述】:
我尝试了没有做任何事情的 css 样式表重置,以及其他解决方案,但没有修复。容器上的边距设置为 0,右侧仍有边距。如果我禁用左边距 0 额外的空白出现在左侧。提前致谢。
body {
padding-top: 50px;
}
.container {
overflow: hidden;
margin-left: 0 auto;
margin-right: 0 auto;
padding: 0 0 0 0;
}
#content {
overflow: auto;
background-color: #FFFFFF;
margin-left: 0;
margin-right: 0;
}
#content-left {
color: #FFFFFF;
float: left;
background-color: #666666;
width: 30%;
}
#content-right {
color: #FFFFFF;
float: right;
background-color: #333333;
width: 70%;
}
<body>
<div class="container" id="main">
<div id="content">
<div id="content-left">
<div>LEFT</div>
</div>
<div id="content-right">
<div>RIGHT</div>
</div>
</div>
</div>
</body>
【问题讨论】:
-
给定的代码工作得很好。 jsfiddle.net/w53Lorh9 可能是您的其他样式导致了问题。
-
将
width: 100%添加到您的.container -
您的 .container 样式有问题...您使用了 margin-left: 0 auto;这是错误的.. margin-left: 0;或左边距:自动;是正确的..你不能一次使用 0 auto with margin-left...