This particular task does not involve using a boostrap grid system. It requires dividing into 12 equal width parts, not 12 blocks of unequal width. To accomplish this, you should utilize display: grid;
.
The code snippet
grid-template-columns: repeat(6, 2fr) repeat(6, 1fr);
specifies that there are 6 occurrences of
2fr
followed by 6 occurrences of
1fr
. The unit
fr
is a relative measure within the grid layout, dividing the available space accordingly. In this case,
2fr
is twice the size of
1fr
. The total row composition is
2fr 2fr 2fr 2fr 2fr 2fr 1fr 1fr 1fr 1fr 1fr 1fr
, totaling 18 parts in a row.
For more information on CSS Grid, you can refer to the following links:
.grid-row {
display: grid;
grid-template-columns: repeat(6, 2fr) repeat(6, 1fr);
grid-auto-rows: auto;
grid-row-gap: .5rem;
grid-column-gap: .5rem;
}
.grid-col {
background: #000;
min-height: 50px;
}
@media (max-width: 500px) {
.grid-row {
grid-template-columns: repeat(3, 2fr) repeat(3, 1fr);
}
}
<div class="grid-row">
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
</div>
If you need columns that are 1.5 times wider instead of twice as wide, you can update the code to
grid-template-columns: repeat(6, 3fr) repeat(6, 2fr);
.grid-row {
display: grid;
grid-template-columns: repeat(6, 3fr) repeat(6, 2fr);
grid-auto-rows: auto;
grid-row-gap: .5rem;
grid-column-gap: .5rem;
}
.grid-col {
background: #000;
min-height: 50px;
}
@media (max-width: 500px) {
.grid-row {
grid-template-columns: repeat(3, 3fr) repeat(3, 2fr);
}
}
<div class="grid-row">
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
<div class="grid-col"></div>
</div>