I have a site built with bootstrap and I want to create a table with swipeable header using the jquery.dragscroll plugin but preserving the fluid grid built-in bootstrap.
So I want to create the headers of the table, and I am using this HTML:
<div class="row-fluid">
<div class="span12">
<div style="overflow:hidden;width:90%;">
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
<div style="display:inline-block;width:100px">some content</div>
</div>
</div>
</div>
The code is here: http://jsfiddle.net/cVfzJ/1/
As we can see in the Fiddle all the divs are visible on two rows, my objective is to have all the divs on a single row (hiding the overflowing divs)
I hope the question is clear
You can force the content of the HTML <div> element stay on the same line by using a little CSS. Use the overflow property, as well as the white-space property set to “nowrap”.
By default, if we have multiple div tags it will be displayed one below the other. In othere words, each div will be displayed in a separate line. To display multiple div tags in the same line, we can use the float property in CSS styles. The float property takes left, right,none(default value) and inherit as values.
If you want to prevent them from wrapping, either remove the white space you have used for formatting, or add white-space:nowrap; to the rule for .
You should have a container for all the <div>
that has width
equal to the sum of all <div>
. Then the parent of this container has to have overflow: auto
.
If you don't know the total width prior to the render you can use JS to calculate it.
Continuing your example:
<div class="row-fluid">
<div class="span12">
<!-- Changed from `hidden` to `auto`. -->
<div style="overflow:auto;width:90%;">
<!-- This is the div that does the trick: -->
<div style="width:1200px;">
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
<div style="display:inline-block;width:100px;">some content</div>
</div>
</div>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With