Issue
I am currently working on a web application and I am trying to figure out how to center two bootstrap buttons side-by-side. It works on mobile, but when I try to inspect the page and view it on a mobile device, they go on separate lines and center (one on top of the other). How can I fix this so that on mobile, they appear side-by-side like on the computer? Here is the code:
<div class="container">
<div class="row justify-content-center">
<div class="col-md-4 col-lg-3 text-center">
<a href="#" style="font-size: 18px;" class="btn btn-primary btn-lg mb-3" role="button">Button 1</a>
</div>
<div class="col-md-4 col-lg-3 text-center">
<a href="#" style="font-size: 18px;" class="btn btn-primary btn-lg mb-3" role="button">Button 2</a>
</div>
</div>
</div>
Solution
How about this. Remove the breakpoints from your columns and make them occupy half the space no matter what screen size you are using:
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row justify-content-center">
<div class="col-6 text-center">
<a href="#" style="font-size: 18px;" class="btn btn-primary btn-lg mb-3" role="button">Button 1</a>
</div>
<div class="col-6 text-center">
<a href="#" style="font-size: 18px;" class="btn btn-primary btn-lg mb-3" role="button">Button 2</a>
</div>
</div>
</div>
Answered By - WillD
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.