Using the fluid grid layout I can get 4 equal spans:
<div class="row-fluid">
<div class="span3">...</div>
<div class="span3">...</div>
<div class="span3">...</div>
<div class="span3">...</div>
</div>
Or I can get 6 equal spans:
<div class="row-fluid">
<div class="span2">...</div>
<div class="span2">...</div>
<div class="span2">...</div>
<div class="span2">...</div>
<div class="span2">...</div>
<div class="span2">...</div>
</div>
But how do I get 5 equal spans?
Second example: instead of adding a number to each col , let bootstrap handle the layout, to create equal width columns: two "col" elements = 50% width to each col, while three cols = 33.33% width to each col. Four cols = 25% width, etc. You can also use . col-sm|md|lg|xl|xxl to make the columns responsive.
The Bootstrap grid system has four classes: xs (for phones - screens less than 768px wide) sm (for tablets - screens equal to or greater than 768px wide) md (for small laptops - screens equal to or greater than 992px wide) lg (for laptops and desktops - screens equal to or greater than 1200px wide)
Bootstrap's grid system can adapt across all six default breakpoints, and any breakpoints you customize. The six default grid tiers are as follow: Extra small (xs)
I have followed bootstraps methods for calculating widths and have come up with the following. You will want to follow the HTML structure of as follows:
<div class="row-fluid-5">
<div class="span2">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</div>
<div class="span2">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</div>
<div class="span2">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</div>
<div class="span2">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</div>
<div class="span2">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</div>
</div>
Then, after you load bootstrap.css and bootstrap-responsive.css, load your custom.css file with the following:
/* CUSTOM 5 COLUMN SPAN LAYOUT
*
* based on http://gridcalculator.dk/
* width => 1200, gutter => 15px, margin => 15px, columns => 5
*/
.row-fluid-5 {
width: 100%;
*zoom: 1;
}
.row-fluid-5:before,
.row-fluid-5:after {
display: table;
line-height: 0;
content: "";
}
.row-fluid-5:after {
clear: both;
}
.row-fluid-5 [class*="span"] {
display: block;
float: left;
width: 100%;
min-height: 30px;
margin-left: 1.875%;
*margin-left: 1.875%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.row-fluid-5 .controls-row [class*="span"] + [class*="span"] {
margin-left: 1.875%;
}
.row-fluid-5 [class*="span"]:first-child{
margin-left: 0;
}
.row-fluid-5 .span2 {
width: 18.5%;
*width: 18.5%;
}
/* responsive ONLY */
@media (max-width: 600px){ /* spans reduce to 100px then go full width */
.row-fluid-5 [class*="span"]{
margin-left: 0;
float: left;
width: 100%;
padding: 10px;
}
}
Check out the demo below to see how it works.
DEMO
Considering that by default bootstrap is 12 columns, you cannot mathematically get 5 equal spans.
However, if you really need to (bad idea, more on that in a second), you can customize your bootstrap download to have 15 columns.
http://twitter.github.com/bootstrap/customize.html
Change the @gridColumns
variable to 15, then use 5 columns all with a span3
.
It is a bad idea though. Bootstrap is 12 columns because 12 works well. Using 12 gives you support for 1/4, 1/3, and 1/2 width columns. With a 15 column layout, you will only have support for 1/3rd width (and a lot of strange other sizes). Your call though, the setting is there.
You need to generate custom grid (e.g. 10). There is no way to create 5 equal raws in 12 column grid
Or you could add this to your css (or the bootstrap.css) - This is my preferred way to solve this. The "15" used to throw me a little bit, but just try to remind yourself it's 1/5th.
.col-xs-15,
.col-sm-15,
.col-md-15,
.col-lg-15 {
position: relative;
min-height: 1px;
padding-right: 10px;
padding-left: 10px;
}
.col-xs-15 {
width: 20%;
float: left;
}
@media (min-width: 768px) {
.col-sm-15 {
width: 20%;
float: left;
}
}
@media (min-width: 992px) {
.col-md-15 {
width: 20%;
float: left;
}
}
@media (min-width: 1200px) {
.col-lg-15 {
width: 20%;
float: left;
}
}
Then just use it like you would any other bootstrap class.
<div class="row">
<div class="col-md-15 col-sm-3">
...
</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