Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to divide bootstrap row into 5 equal parts?

I want to divide bootstrap row into 5 equal parts. It includes 12-col-md, so how i can divide it into equal 5 parts?

Can anyone help me to solve this problem?

like image 619
anuruddhika Avatar asked Mar 17 '15 06:03

anuruddhika


People also ask

How do I make 5 divs in a row?

Write a basic HTML template using these files. Once everything is set up, create a simple 'container' div inside <body> tag. Inside the 'container', create another div with class 'row' and as the name suggests, we are creating a row for handling columns. Populate the 'row' div with 5 divs with class 'col'.

How do I split a row into 6 columns in Bootstrap?

You can use the row-cols-* (eg: row-cols-3 , row-cols-md-3 ) class for your requirement.

How do I divide div into 5 columns?

You can get the 5 colums to wrap within the same . row using a clearfix break such as <div class="col-12"></div> or <div class="w-100"></div> every 5 columns. As of Bootstrap 4.4, you can also use the row-cols-5 class on the row ...

How do I make 5 columns in one line in Bootstrap?

First example: create a row ( <div class="row"> ). Then, add the desired number of columns (tags with appropriate . col-*-* classes). The first star (*) represents the responsiveness: sm, md, lg, xl or xxl, while the second star represents a number, which should add up to 12 for each row.


2 Answers

A great way to resolve this is here!

By default Bootstrap does not provide grid system that allows us to create five columns layout, but as you can see it’s quite simple. At first you need to create default column definition in the way that Bootstrap do it. I called my classes col-..-15.

.col-xs-15,
.col-sm-15,
.col-md-15,
.col-lg-15 {
    position: relative;
    min-height: 1px;
    padding-right: 10px;
    padding-left: 10px;
}

Next you need to define width of new classes in case of different media queries.

.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;
    }
}

Now you are ready to combine your classes with original Bootstrap classes. For example, if you would like to create div element which behave like five columns layout on medium screens and like four columns on smaller ones, you just need to use something like this:

<div class="row">
    <div class="col-md-15 col-sm-3">
    ...
    </div>
</div>
like image 59
Fernando Madriaga Avatar answered Oct 13 '22 23:10

Fernando Madriaga


Old bootstrap Version

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>

Five equally spaced and centered columns.


In bootstrap 3.0 and 4 alpha.
<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>


CUSTOM STYLE

Custom Styles

.container {width:100%; float:left;}
.col1{ width:20%; float:left}

Latest Table style

.container {width:100%;display:table;}
.col1{ width:20%; display:table-cell;}
like image 28
Ravi Delixan Avatar answered Oct 13 '22 22:10

Ravi Delixan