Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Make 1/5 Column Grid in Bootstrap 3

I have a layout which I need to put three Div beside each other as:

<div class="row">
    <div class="col-md-1.5" id="legend"></div>
    <div class="col-md-0.5" id="icon"></div>
    <div class="col-md-10"  id="map"></div>
</div>

I know it possible to get the legend and icon div inside one row but I need to keep them separate while the legend will be slide-able and in that case I have to replace the col-md-10 from map with col-md-11.5.

Can you lease let me know how I can do this?

like image 640
Suffii Avatar asked Mar 27 '14 15:03

Suffii


People also ask

How do I make 5 columns in Bootstrap?

First example: create a row ( <div class="row"> ). Then, add the desired number of columns (tags with appropriate .col-*-* classes).

Does Bootstrap 3 have a grid system?

The Bootstrap 3 grid system has four tiers of classes: xs (phones), sm (tablets), md (desktops), and lg (larger desktops). You can use nearly any combination of these classes to create more dynamic and flexible layouts.

How do I make 5 columns in Bootstrap 4?

Populate the 'row' div with 5 divs with class 'col'. Because Bootstrap 4.0+ grid system has now shifted to Flexbox, the columns will arrange by themselves into five equally sized DOM elements.

How do I change the grid size in Bootstrap?

Go to the Customize menu on Bootstrap website and choose your preferred size. In Less Variables -> Grid system you can find a form to input your preferred sizes. Then you can easily download the preferred grid. Hope this will help.


1 Answers

Bootstrap 3

Use nesting like this..

<div class="row">
    <div class="col-md-2">
       <div class="col-md-9" id="legend"></div>
       <div class="col-md-3" id="icon"></div>
    </div>
    <div class="col-md-10" id="map"></div>
</div>

http://www.bootply.com/125259

Update for Bootstrap 4

Here's a 1/5 column in Bootstrap 4 (no extra CSS or SASS) using the auto-layout grid..

<div class="container-fluid">
    <div class="row">
        <div class="col-2">2</div>
        <div class="col-2">2</div>
        <div class="col-2">2</div>
        <div class="col-2">2</div>
        <div class="col">1/5</div>
    </div>
</div>

http://www.codeply.com/go/gjmzB4MTMe

This solution works because Bootstrap 4 is now flexbox. You can get the 5 colums to wrap witin the same .row using a clearfix break such as <div class="col-12"></div> or <div class="w-100"></div> very 5 columns.

like image 99
Zim Avatar answered Oct 17 '22 05:10

Zim