html - 引导行中的水平可滚动 div

标签 html css list twitter-bootstrap-3 scrollable

我正在尝试制作一个水平可滚动的 Bootstrap 行。该行包含包装在 div 中的客户评论。每个推荐 div 的宽度是 33.333%

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>

最佳答案

请检查。这是您想要实现的目标吗?

horizontal scrolling

CodePenJSFiddle

/* 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>

用于 Bootstrap 4

谢谢 Hector对于comment !

https://codepen.io/glebkema/pen/xxOgaMm

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

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

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

关于html - 引导行中的水平可滚动 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38901166/

相关文章:

python - 如何在 Python 中创建不可变列表?

html - 网格格式提供额外的空白空间

html - 删除 option 和 optgroup 之间的空格

html - 没有明显原因的移动网站右侧的间距 Wordpress 主题

python - 仅当部分单词尚未在列表中时才追加

java - 包含多个 "keys"的列表对象

javascript - Twitter Bootstrap Javascript - 如何仅使用工具提示库?

jquery - 从 iframe 调用父级中的 Fancybox

javascript - Overflow-y 在 javascript 中不起作用?

css - 覆盖 Struts 2 jqGrid CSS