Trying to achieve an autofit for the second column width using the code provided (view code here), but the use of auto margins doesn't seem to be effective.
.col {
border: 1px solid red;
}
.autofit {
margin: auto;
width: auto;
max-width: auto;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row m-5">
<div class="col">1</div>
<div class="col autofit">2*</div>
<div class="col">3</div>
<div class="col">4</div>
</div>
Are there alternative methods to achieve the autofit for the column width?
Tried using width: fit-content(100px);
as well, but it did not yield the desired results...