我正试图让浅绿色消失(没有消失但是在深绿色之下)。
这与我之前的帖子(Remove padding/margin between elements in shrink-to-fit container)完全相同,但唯一不同的是换行是在另一个换行中,没有零边距/填充,显示内联块或溢出都有效。
#footer-left{
float:left;
width:700px;
height:200px;
background:#CC3;
}
#footer-services-contents-wrap{
background:#030;
width:auto;
height:auto;
display:inline-block;
}
#footer-services-title-wrap{
background:#0F0;
width:auto;
height:auto;
display:inline-block;
}
.footer-wrap-left{
width:auto;
height:auto;
display: inline-block;
border-left:1px solid #ccc;
padding-left:50px;
padding:0;
border:none;
float:left;
}
ul.footer {
list-style-type:none;
padding: 0px;
color:#666;
font-weight:100;
font-family:verdana,arial,"Times New Roman", Times, serif,georgia,serif,helvetica;
font-size:20px;
margin: 10px 0 0 0;
}
.footer-wrap-right{
width:auto;
height:auto;
display: inline-block;
border-left:1px solid #ccc;
padding-left:50px;
padding:0 0 0 50px;
border:none;
float:left;
}
<div id="footer-left">
<div id="footer-services-title-wrap">
<div id="footer-services-contents-wrap">
<div class="footer-wrap-left">
<f1>text goes here</f1>
<ul class="footer">
<li>text text</li>
<li>text text</li>
<li>text text</li>
</ul>
</div>
<div class="footer-wrap-right">
<f1>more text goes here</f1>
<ul class="footer">
<li>text text</li>
<li>text text</li>
<li>text text</li>
</ul>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
将float:left
添加到#footer-services-contents-wrap
发生这种情况的原因:
块格式化上下文对于定位非常重要(请参阅 漂浮物)和清除浮体(见清楚)。定位规则 并且清除浮动仅适用于同一块内的事物 格式化上下文浮点数不会影响其他事物的布局 阻止格式化上下文,并清除只清除过去的浮动 相同的块格式化上下文。
https://www.w3.org/TR/CSS2/visuren.html#block-formatting
#footer-left{
float:left;
width:700px;
height:200px;
background:#CC3;
}
#footer-services-contents-wrap{
background:#030;
width:auto;
height:auto;
display:inline-block;
float: left;
}
#footer-services-title-wrap{
background:#0F0;
width:auto;
height:auto;
display:inline-block;
}
.footer-wrap-left{
width:auto;
height:auto;
display: inline-block;
border-left:1px solid #ccc;
padding-left:50px;
padding:0;
border:none;
float:left;
}
ul.footer {
list-style-type:none;
padding: 0px;
color:#666;
font-weight:100;
font-family:verdana,arial,"Times New Roman", Times, serif,georgia,serif,helvetica;
font-size:20px;
margin: 10px 0 0 0;
}
.footer-wrap-right{
width:auto;
height:auto;
display: inline-block;
border-left:1px solid #ccc;
padding-left:50px;
padding:0 0 0 50px;
border:none;
float:left;
}
&#13;
<div id="footer-left">
<div id="footer-services-title-wrap">
<div id="footer-services-contents-wrap">
<div class="footer-wrap-left">
<f1>text goes here</f1>
<ul class="footer">
<li>text text</li>
<li>text text</li>
<li>text text</li>
</ul>
</div>
<div class="footer-wrap-right">
<f1>more text goes here</f1>
<ul class="footer">
<li>text text</li>
<li>text text</li>
<li>text text</li>
</ul>
</div>
</div>
</div>
</div>
&#13;
答案 1 :(得分:1)
在float:left
和inline-block
课程中使用footer-wrap-right
时,您不需要footer-wrap-left
:
#footer-left{
float:left;
width:700px;
height:200px;
background:#CC3;
}
#footer-services-contents-wrap{
background:#030;
width:auto;
height:auto;
display:inline-block;
}
#footer-services-title-wrap{
background:#0F0;
width:auto;
height:auto;
display:inline-block;
}
.footer-wrap-left{
width:auto;
height:auto;
display: inline-block;
border-left:1px solid #ccc;
padding-left:50px;
padding:0;
border:none;
}
ul.footer {
list-style-type:none;
padding: 0px;
color:#666;
font-weight:100;
font-family:verdana,arial,"Times New Roman", Times, serif,georgia,serif,helvetica;
font-size:20px;
margin: 10px 0 0 0;
}
.footer-wrap-right{
width:auto;
height:auto;
display: inline-block;
border-left:1px solid #ccc;
padding-left:50px;
padding:0 0 0 50px;
border:none;
}
<div id="footer-left">
<div id="footer-services-title-wrap">
<div id="footer-services-contents-wrap">
<div class="footer-wrap-left">
<f1>text goes here</f1>
<ul class="footer">
<li>text text</li>
<li>text text</li>
<li>text text</li>
</ul>
</div>
<div class="footer-wrap-right">
<f1>more text goes here</f1>
<ul class="footer">
<li>text text</li>
<li>text text</li>
<li>text text</li>
</ul>
</div>
</div>
</div>
</div>