Bootstrap:需要帮助使按钮居中

Bootstrap: Need help to center a button

我正在尝试将此按钮居中,但似乎无法正常工作,非常感谢您的帮助。

<div class="cta-btn">
                                    <a class="btn btn-cta text-center" href="#" role="button">EXPLORE</a>
                            </div>

还有 CSS

 .btn-cta{
   padding: 25px 80px;
   border: 3px solid white;
   background-color: transparent;
   color: white;
   font-family: Tahoma, Verdana, Segoe, sans-serif;
   text-transform: uppercase;
   font-size: 1.4em;
   transition: all 0.3s ease;
}

您是否尝试添加 text-align: center;

使用 class 文本中心

<div class="cta-btn text-center">
                                    <a class="btn btn-cta text-center" href="#" role="button">EXPLORE</a>
                            </div>

.text-center class 放在封闭的 div

<div class="cta-btn text-center">
    <a class="btn btn-cta" href="#" role="button">EXPLORE</a>
</div>

此外,如果您希望按钮填充 div 的宽度,请将 .btn-block class 添加到按钮。

display: block;
margin: 0 auto;