child div不显示-背景颜色不变



请告诉我的代码出了什么问题?为什么没有背景颜色应用于子divs

<div class="col-xs-2 line wall-left" style="position:
 relative; width: 3%; height: 636px; float: left; top: -80px;">
<div style="width:50%;background:black;"></div>
<div style="width:50%;background:white;"></div>
</div>

为内部div标记定义维度,并增加外部div的宽度以查看输出。

<div class="col-xs-2 line wall-left" style="position: relative; width: 3%; height: 636px; float: left; top: -80px; ">
<div style="width:50%;background:black; height:100%"></div>
<div style="width:50%;background:white; height:100%"></div>
</div>

您可以根据自己的需求调整div位置

像这样尝试

<div class="col-xs-2 line wall-left" style="position:
 relative; width: 367%; ; float: left; top: 80px;">
<div style="width:50%;background:black;">sdfgsdfgsdfg</div>
<div style="width:50%;background:gray;">dsfgsdfgsdfg</div>
</div>

#请添加以px为单位的高度。像这样并删除位置:相对#

<div class="col-xs-2 line wall-left" style="width: 3%; height: 636px; float: left; top: -80px;">
<div style="width:50%;background:black;height:50px;"></div>
<div style="width:50%;background:white;height:50px;"></div>
</div>

您需要添加高度。

 <div class="col-xs-2 line wall-left" style="position:
 relative; width: 200px; height: 636px; float: left; top: 0px;">
   <div style="width:100px; height:50px; background:red; float:left;">Test</div>
   <div style="width:100px; height:50px; background:yellow; float:right;">Demo</div>
 </div>

试试这个

<div class="col-xs-2 line wall-left" style="position: relative; width: 100%; ; float: left; top: 80px;">
 <div style="width:50%;background:black;height:20em"></div>
 <div style="width:50%;background:gray;height:20em"></div>
</div>

最新更新