如何设置float-x scroll with float left,如果将float left设置为sub div,则无法滚动因为sub div设置在screen.and不能设置宽度为父div,因为sub div是动态的。
.parent div{
overflow-x:scroll;
display:Block;
}
.sub div{
float:left;
}
答案 0 :(得分:2)
尝试
.parent{
overflow-x:scroll;
display:Block;
white-space: nowrap;
}
.parent .sub{
/*float:left;*/
display:inline-block;
margin-right:10px;
border:1px solid red;
}
<div class="parent">
<div class="sub">
testing</div>
<div class="sub">
testing testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
<div class="sub">
testing</div>
</div>