我希望有一行可以水平滚动列:
如您所见,该行是外部块(带填充)。在其中,有一些列,每个列都有一些span*
类,例如span3
。由于所有列都不适合行,滚动条位于底部。
这是我尝试做的事情(使用内联css),到目前为止没有运气。
<div class="row">
<!-- the parent element which will have scrollbar -->
<div class="span12" style="white-space: nowrap; overflow-x: auto;">
<div class="row">
<div class="span3" style="display: inline-block;">content here</div>
<div class="span3" style="display: inline-block;">content here</div>
<div class="span3" style="display: inline-block;">content here</div>
...
<div>
</div>
</div>
然后,一旦它们无法放入行中,列就会换行。我怎么能这样做?
谢谢。
答案 0 :(得分:19)
<强>更新强>
我猜你错过了float: none;
:float
部队display: block;
。
<div class="myClass">
<div class="row">
<div class="span5"></div>
<div class="span5"></div>
<div class="span5"></div>
</div>
</div>
div.myClass {
overflow-x: auto;
white-space: nowrap;
}
div.myClass [class*="col"], /* TWBS v3 */
div.myClass [class*="span"] { /* TWBS v2 */
display: inline-block;
float: none; /* Very important */
}
无论如何,这不是因为你可以做到你应该这样做。像carousels这样的东西可以达到这种效果。
恕我直言网页原本是水平滚动,而JavaScript可以做任何事情。
答案 1 :(得分:2)
我接受了一点。可滚动的水平列!
div.h-scrollable {
overflow-x: auto;
white-space: nowrap;
}
div.h-scrollable [class*="col"] {
display: inline-block;
float: none;
white-space: normal;
vertical-align: top;
}
<div class="h-scrollable container-fluid ">
<div class="row">
<div class="col-xs-1">
<label>9:00am</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blah</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blah</label>
</div>
<div class="col-xs-6">
<label>BBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahah</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blah</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blah</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blah</label>
</div>
</div>
<div class="row">
<div class="col-xs-1">
<label>9:00am</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blah</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blah</label>
</div>
<div class="col-xs-6">
<label>BBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahBlah blah blah blah blah blahah</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blah</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blah</label>
</div>
<div class="col-xs-6">
<label>Blah blah blah blah blah blah</label>
</div>
</div>
</div>
答案 2 :(得分:-1)
你需要span3上的overflow-x而不是我认为的span12