Im trying to create a navigation bar for my table using twitter bootstrap.
The end result would look something like this
Im trying to use bootstraps grid system for this and seem to have gotten the showing rows part to look as planned but cant get the buttons to be responsive when the user switches to mobile.
HTML
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8"> <!-- controls !-->
<div class="col-xs-12 col-sm-12">
<a href="#">Back</a>
</div>
<div class="col-xs-12 col-sm-12">
<a href="#">First</a>
</div>
<div class="col-xs-12 col-sm-12">
<a href="#">Previous</a>
</div>
<div class="col-xs-12 col-sm-12">
<a href="#">Next</a>
</div>
<div class="col-xs-12 col-sm-12">
<a href="#">Last</a>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4"><!-- page number !-->
<div class="pull-right">
<span>Showing rows 1 to 10 of 20</span>
</div>
</div>
</div>
</div>
The buttons seem to only render on top of each other.
Here is a jsfiddle showing whats happening.
2
Answers
Each of your button is wrapped in a div with a bootstrap class “col-sm-12” and “col-xs-12” . This means that each of those div will occupy 12 columns EACH, thereby leaving no column for other buttons or divs to lie on the same row.
To obtain the desired result, change their classes to “col-sm-2” so that each button’s div occupies two columns out of twelve.
What about a button group?
EDIT added in showing rows and made more responsive on mobile devices