I want to have 5 equal columns on a page I am building and I can't seem to understand how the 5 column grid is being used here: http://web.archive.org/web/20120416024539/http://domain7.com/mobile/tools/bootstrap/responsive
Is the five column grid being demonstrated above part of the twitter bootstrap framework?
Basic Structure of a Bootstrap 5 Grid First example: create a row ( <div class="row"> ). Then, add the desired number of columns (tags with appropriate . col-*-* classes).
Also, you could build your own 7-columns version of Twitter Bootstrap by using the Custom Builder (Changing the @grid-columns , ...). If you are using less compiler, you could download the less version of Twitter Bootstrap (from Github) and edit the variables. less file instead. +1 for custom builder.
Bootstrap 4 now uses flexbox by default, so you get access to its magical powers straight out of the box. Check out the auto layout columns that dynamically adjust width depending on how many columns are nested.
Here's an example:
<div class="row"> <div class="col"> 1 of 5 </div> <div class="col"> 2 of 5 </div> <div class="col"> 3 of 5 </div> <div class="col"> 4 of 5 </div> <div class="col"> 5 of 5 </div> </div>
WORKING DEMO
A fantastic full width 5 columns layout with Twitter Bootstrap was created here.
This is by far the most advanced solution since it works seamlessly with Bootstrap 3. It allows you to re-use the classes over and over again, in pair with the current Bootstrap classes for responsive design.
CSS:
Add this to your global stylesheet, or even to the bottom of your bootstrap.css
document.
.col-xs-5ths, .col-sm-5ths, .col-md-5ths, .col-lg-5ths { position: relative; min-height: 1px; padding-right: 15px; padding-left: 15px; } .col-xs-5ths { width: 20%; float: left; } @media (min-width: 768px) { .col-sm-5ths { width: 20%; float: left; } } @media (min-width: 992px) { .col-md-5ths { width: 20%; float: left; } } @media (min-width: 1200px) { .col-lg-5ths { width: 20%; float: left; } }
Put it to use!
For example, if you want to create a div element that behaves like a five column layout on medium screens and like two columns on smaller ones, you just need to use something like this:
<div class="row"> <div class="col-md-5ths col-xs-6"> ... </div> </div>
WORKING DEMO - Expand the frame to see the columns become responsive.
ANOTHER DEMO - Incorporating the new col-*-5ths
classes with others such as col-*-3
and col-*-2
. Resize the frame to see them all change to col-xs-6
in responsive view.
Use five divs with a class of span2 and give the first a class of offset1.
<div class="row-fluid"> <div class="span2 offset1"></div> <div class="span2"></div> <div class="span2"></div> <div class="span2"></div> <div class="span2"></div> </div>
Voila! Five equally spaced and centered columns.
In bootstrap 3.0, this code would look like
<div class="row"> <div class="col-md-2 col-md-offset-1"></div> <div class="col-md-2"></div> <div class="col-md-2"></div> <div class="col-md-2"></div> <div class="col-md-2"></div> </div>
Since bootstrap 4.0 uses Flexbox by default:
<div class="row"> <div class="col"></div> <div class="col"></div> <div class="col"></div> <div class="col"></div> <div class="col"></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