I am working on some HTML/CSS code that utilizes Bootstrap 5.2 and the justify-content-between
class in order to move two buttons to the edges of a container.
<div class="container">
<div class="row">
<div class="col-12">
<ul class="d-flex justify-content-center align-items-center bg-grey">
<li>Test</li>
</ul>
</div>
<div class="col-12">
<div class="row justify-content-between">
<div class="col-2 text-start">
<button class="btn btn-primary btn-lg">LEFT</button>
</div>
<div class="col-2 text-end">
<button class="btn btn-primary btn-lg">RIGHT</button>
</div>
</div>
</div>
</div>
</div>
This is how I would like the layout to appear - with the LEFT
and RIGHT
buttons aligned perfectly to the edges.
https://i.sstatic.net/nQZh6.png
Everything looks good until the viewport width goes below 768px (sm or xs), at which point the RIGHT
button overflows.
https://i.sstatic.net/caNHz.png
I can adjust the margin at specific responsive breakpoints, but I feel like there might be a more efficient solution without having to do that.
Is there a correct or better method to achieve this desired layout?