In order to dynamically calculate the width of a column based on the 12 columns in the grid, you can create a custom class.
By dividing 100%
by 12, you get the width of one column, which can then be multiplied by 1.5 for customization.
To match Bootstrap's default padding of 15px
on both left and right sides for their .col
classes, I included padding: 0 15px
in the custom class.
A media
query is used to reset the column width to 100%, aligning with the behavior of Bootstrap's col-sm
classes.
The specific screen widths for each breakpoint utilized by Bootstrap can be referenced in their documentation.
.row {
width: 100%;
}
.column {
border: 1px solid black;
text-align: right;
}
.col-sm-1-half {
width: calc((100% / 12) * 1.5);
padding: 0 15px;
}
/* bootstrap sm breakpoint */
@media only screen and (max-width: 576px){
.col-sm-1-half {
width: 100%;
}
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d8bab7b7acabacaab9a898ecf6ecf6e9">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="column col-sm-2">
1
</div>
<div class="column col-sm-1-half">
2
</div>
<div class="column col-sm-2">
3
</div>
</div>