2016-07-27 147 views
0

如何設置overflow-x滾動使用浮動左側,如果設置浮動左側子div,無法滾動,因爲sub div設置在screen.and不能設置寬度爲父div因爲子div是動態的。在css中溢出滾動的浮動

.parent div{ 
    overflow-x:scroll; 
    display:Block; 
} 
.sub div{ 
    float:left; 
} 
+0

請粘貼代碼 –

+0

.parent DIV { 溢出-X:滾動; 顯示:Block; } .sub div {float:left; } –

回答

1

嘗試

.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>

+0

非常感謝你的親愛的lalji tadhani。得到它了。 –