I'm trying to create a Grid of Tiles with Bootstrap with the following properties:
It should look like this:
body{
background: #a5b5c5;
background:lightblue !important;
}
.box{
height: 180px;
width: 180px;
background: #fff;
border-radius: 4px;
}
.col-lg-2, .col-md-3, .col-xs-6{
margin-top: 12px !important;
}
<div class="container">
<div class="row">
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
<div class="col-lg-2 col-md-3 col-xs-6 ">
<div class="box"></div>
</div>
</div>
</div>
What should I do to accomplish a responsiveness which sustains my properties?
Thanks!!
You didn't mention specific box
dimensions, only that they should remain square. In that case, use margin-top:30px
to corresponding with the Bootstrap gutter width, and padding-bottom: 100%;
on the box
.
.box {
background: #fff;
border-radius: 4px;
padding-bottom: 100%;
}
.col-lg-2, .col-md-3, .col-xs-6{
margin-top: 30px !important;
}
Bootstrap 3 demo
Bootstrap 4 demo
Note: Setting a px
size on the .box
(ie:width:180px;height:180px
) will prevent the boxes from resizing responsively.
You can increase the gutter by changing margins and padding. Margin is double the padding for example...
.col-lg-2, .col-md-3, .col-xs-6{
padding-left: 30px;
padding-right: 30px;
margin-top: 60px;
}
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