Cod*_*n25 25 html css list scrollable twitter-bootstrap-3
我正在尝试make一个水平可滚动的bootstrap行.该行包含div包含的客户评论.每个见证div的宽度是33.333%.
white-space: nowrap并且display: 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>
Run Code Online (Sandbox Code Playgroud)
Gle*_*sky 66
请检查.这是你想要达到的目标吗?

/* 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; }Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
小智 16
在Bootstrap 4中,您需要添加
flex-wrap: nowrap;
Run Code Online (Sandbox Code Playgroud)
至
.testimonial-group > .row
Run Code Online (Sandbox Code Playgroud)
除了格列布的答案
小智 6
弹性盒方法
/* The heart of the matter */
.testimonial-group > .row {
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
}
.testimonial-group > .row > .col-xs-4 {
flex: 0 0 auto;
}
/* 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; }Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
您可以使用:
class="text-nowrap overflow-auto"
Run Code Online (Sandbox Code Playgroud)
考虑这个例子:
class="text-nowrap overflow-auto"
Run Code Online (Sandbox Code Playgroud)
要在没有任何 css 或所有不需要的 div 的情况下实现所需的结果:getbootstrap.com/list-group。
小智 5
尝试这个:
section-title {
width: 100%;
overflow-x: scroll(or auto);
}
Run Code Online (Sandbox Code Playgroud)
看看这里的规格。
| 归档时间: |
|
| 查看次数: |
61786 次 |
| 最近记录: |