2016-08-11 46 views
8

我正在嘗試使水平滾動引導行成爲可能。該行包含用div包裝的顧客評論。每個見證div的寬度是33.333%引導行中的水平可滾動div

white-space: nowrapdisplay: inline-block不起作用。

我在做什麼錯?

<div class="row"> 
    <div class="col-lg-12 text-center"> 
     <div class="section-title"> 
      <div class="testimonial_group"> 
       <div class="testimonial">...</div> 
       <div class="testimonial">...</div> 
       <div class="testimonial">...</div> 
       <div class="testimonial">...</div> 
       ... 
      </div> 
     </div> 
    </div> 
</div> 
+0

請分享的jsfiddle – GSB

回答

23

請檢查。這是你想要達到的目標嗎?

horizontal scrolling

CodePen   •   JSFiddle

/* The heart of the matter */ 
 
.testimonial-group > .row { 
 
    overflow-x: auto; 
 
    white-space: nowrap; 
 
} 
 
.testimonial-group > .row > .col-xs-4 { 
 
    display: inline-block; 
 
    float: none; 
 
} 
 

 
/* Decorations */ 
 
.col-xs-4 { color: #fff; font-size: 48px; padding-bottom: 20px; padding-top: 18px; } 
 
.col-xs-4:nth-child(3n+1) { background: #c69; } 
 
.col-xs-4:nth-child(3n+2) { background: #9c6; } 
 
.col-xs-4:nth-child(3n+3) { background: #69c; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 

 
<div class="container testimonial-group"> 
 
    <div class="row text-center"> 
 
    <div class="col-xs-4">1</div><!-- 
 
--><div class="col-xs-4">2</div><!-- 
 
--><div class="col-xs-4">3</div><!-- 
 
--><div class="col-xs-4">4</div><!-- 
 
--><div class="col-xs-4">5</div><!-- 
 
--><div class="col-xs-4">6</div><!-- 
 
--><div class="col-xs-4">7</div><!-- 
 
--><div class="col-xs-4">8</div><!-- 
 
--><div class="col-xs-4">9</div> 
 
    </div> 
 
</div>

+0

..great你的代碼!它的工作現在但我無法通過觸控板滾動列表或一隻老鼠。我只能用鍵盤來滾動它。有沒有解決這個問題的方法?... – Codehan25

+0

@ Codehan25我猜這個行在第一次點擊進入該行後就變成了可滾動的。 –

+0

不幸的是沒有... – Codehan25

1

試試這個:

section-title { 
    width: 100%; 
    overflow-x: scroll(or auto); 
} 

the spec here

+0

..won't工作:( – Codehan25

1

把這幾行CSS文件

.section-title { 
    overflow: scroll; 
    overflow-x: scroll; 
    overflow-y:hidden 
} 

的x是水平和y是垂直,在許多div的嵌套父DIV應用類代碼。