如何为全文制作背景色。我想输出(使用CSS)。
<div class="" style="background-color:red; clear: both;padding-top:10px;" id="test">
<div style="float:left;">
<input type="checkbox" class="chk" style="display: none;">
</div>
<div style="width:946px;">
<div class="portlet-content" style="background-color:blue;">
<div style="float: left; padding-right: 10px; text-align: right; padding-left: 25px;" >
<b><span style="font-size:11.0pt">4)</span></b>
</div>
<div style="float: left; width: 775px; word-wrap: break-word; text-align: justify;" >
<span style="font-size:12pt">
<span style="font-size:14.0pt">test content test content test content test content test content test content.</span>
</span>
</div>
</div>
</div>
</div>
&#13;
在我的情况下如何使用css?
答案 0 :(得分:2)
只需将overflow: auto
添加到红色背景的div:
<div class="" style="background-color:red; clear: both;padding-top:10px;overflow:auto" id="test">
<div style="float:left;">
<input type="checkbox" class="chk" style="display: none;">
</div>
<div style="width:946px;">
<div class="portlet-content" style="background-color:blue;">
<div style="float: left; padding-right: 10px; text-align: right; padding-left: 25px;">
<b><span style="font-size:11.0pt">4)</span></b>
</div>
<div style="float: left; width: 775px; word-wrap: break-word; text-align: justify;">
<span style="font-size:12pt">
<span style="font-size:14.0pt">test content test content test content test content test content test content.</span>
</span>
</div>
</div>
</div>
</div>
当你浮动一个子元素时,父元素的容器会崩溃,就好像孩子没有占用空间一样。
答案 1 :(得分:1)
overflow: auto
的CSS中, div
应该可以解决问题
答案 2 :(得分:0)
使用clear div添加此代码。
<div class="" style="background-color:red; clear: both;padding-top:10px;" id="test">
<div style="float:left;">
<input type="checkbox" class="chk" style="display: none;">
</div>
<div style="width:946px;">
<div class="portlet-content" style="background-color:blue;">
<div style="float: left; padding-right: 10px; text-align: right; padding-left: 25px;" >
<b><span style="font-size:11.0pt">4)</span></b>
</div>
<div style="float: left; width: 775px; word-wrap: break-word; text-align: justify;" >
<span style="font-size:12pt">
<span style="font-size:14.0pt">test content test content test content test content test content test content.</span>
</span>
</div>
<div style="clear:both; display:block;"></div>
</div>
</div>
</div>