I'm trying to have two unequal columns in Bootstrap. I want to have one column on each side (so if there are columns from 1 to 12, 1 and 12 will be empty), and col-md-2~5 is one column, and 6~11 is another column.
I can't really find an example for this (other than the offset). Can someone help me?
. col-md- (medium devices - screen width equal to or greater than 768px) . col-lg- (large devices - screen width equal to or greater than 992px) .
col-md-offset-* to leave a particular number of virtual Bootstrap columns to the left of any column (kind of like invisible place holders).
col-md-4: This class is used when the device size is medium or greater than 768px and the maximum width of container is 720px and you want the width equal to 4 columns.
Use offsets. You only need to define the first offset as the second col will float next to the first.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/> <div class="container"> <div class="row"> <div style="background:#f99" class="col-xs-4 col-xs-offset-1">Cols 2-5</div> <div style="background:#9f9" class="col-xs-6">Cols 6-11</div> </div> </div>
Note: I'm using the xs
column size so it works in the snippet frame.
Note, for Bootstrap 4, the offset classes use different names. The col-*-offset-*
classes become .offset-*
.
See http://upgrade-bootstrap.bootply.com/ for a handy migration guide
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <div class="container"> <div class="row"> <div style="background:#f99" class="col-4 offset-1">Cols 2-5</div> <div style="background:#9f9" class="col-6">Cols 6-11</div> </div> </div>
See https://getbootstrap.com/docs/4.3/layout/grid/#offsetting-columns
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