Instead of adding multiple .rows
, an alternative approach is to utilize a .w-100
div that is visible only on large devices (using .d-none
to generally hide it and .d-lg-block
for display, breaking the line on large screens).
When combined with .justify-content-center
, this achieves the desired outcome. See below for a minimal working example:
.col-6 {
border: 1px solid gray;
}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="75051a050510075b1f0635445b44475b4c">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="31535e5e45424543504171051f011f01">[email protected]</a>/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7f1d10100b0c0b0d1e0f3f4b514f514f">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="row justify-content-center">
<div class="col-6 col-lg-3">1</div>
<div class="col-6 col-lg-3">2</div>
<div class="col-6 col-lg-3">3</div>
<div class="w-100 d-none d-lg-block"></div>
<div class="col-6 col-lg-3">4</div>
<div class="col-6 col-lg-3">5</div>
<div class="col-6 col-lg-3">6</div>
</div>
Display on small devices:
https://i.sstatic.net/H00wc.png
Display on large devices:
https://i.sstatic.net/WBV2i.png