[英]Centering Bootstrap5 buttons on mobile
I am currently working on a web application and I am trying to figure out how to center two bootstrap buttons side-by-side.我目前正在研究 web 应用程序,我正在尝试弄清楚如何将两个引导按钮并排居中。 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).
它适用于移动设备,但是当我尝试检查页面并在移动设备上查看它时,它们 go 位于不同的行和中心(一个在另一个之上)。 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>
How about this.这个怎么样。 Remove the breakpoints from your columns and make the 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>
This might look more cleaner这可能看起来更干净
<div class="col-xl-12" style="display:flex">
<div class="btns" style="margin:auto">
<a class="btn btn-primary" href="">Button1 </a>
<a class="btn btn-primary" href="">Button2 </a>
</div>
</div>
</div>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.