Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to overlap columns in Bootstrap 3?

I'd like to create single row with two overlapping columns like that:

.row
  .col-sm-7
  .col-sm-6

so that 6th column of the grid is overlapped.

It's partially possible with a .col-sm-pull-1:

.row
  .col-sm-6
  .col-sm-6.col-sm-pull-1

but the 12th column becomes empty. I tried:

.row
  .col-sm-6
  .col-sm-7.col-sm-pull-1

but the second column moves to the next row.

I found the answer for Bootstrap 2 (How to overlap columns using twitter bootstrap?). Is it possible with the Bootstrap 3?

like image 596
d3m0n Avatar asked Nov 14 '15 20:11

d3m0n


People also ask

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 overlap images in Bootstrap?

To make overlay effect just add . hover-overlay to the image container.

Can we use more than 12 columns in Bootstrap?

The Bootstrap grid has only 12 columns, so you should never have more than 12 columns in a row. You should have only 3 col-md-4 in each .


2 Answers

After seeing your image example, I think perhaps this is what you are looking for. (I made them overlap 2 columns because that will center it better)

.blue{
    background-color: rgba(0,0,255,0.5);;
}
.row .red{
    background-color: rgba(255,0,0,0.5);
    position: absolute;
}
.red, .blue {
    height: 70px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
    <div class="row">
        <div class="red col-xs-7"></div>
        <div class="blue col-xs-7 col-xs-push-5"></div>
    </div>
</div>
like image 186
turbopipp Avatar answered Sep 29 '22 01:09

turbopipp


Fiddle If you want to overlap the two columns in one row, you'll need negative margins. The bootstrap gutters/margins are layed out using positive and negative margins. I would recommend ids for the columns and then you can use z-index if you want one over the other one. So change right margin on first and left margin on the second.

margin-right: -5%; 
margin-left: -5%;

How the grid works is a great reference for how its built.

like image 25
1Bladesforhire Avatar answered Sep 29 '22 01:09

1Bladesforhire