css - 使用引导程序 4.0 将一行与中心对齐
问题描述
我有以下使用引导程序 4 的标记:-
<div class="container">
<div class="row">
<div class="col-xl-4 col-md-6 col-lg-4">
<div class="footer_widget">
<h3 class="footer_title">
Enter your number
</h3>
<form asp-action="Search" method="get" class="newsletter_form">
<input type="text" name="number" placeholder="Enter your number" style="height: 50px;
background: #fff;
padding-left: 20px;
font-size: 15px;
color: #000;
border: 1px solid #596672;
border-radius: 30px;
width: 100%;">
<button type="submit" style="
position: absolute;
height: 40px;
border: none;
color: #fff;
background: #2EBDBE;
padding: 0 22px;
cursor: pointer;
border-radius: 30px;
top: 5px;
right: 5px;
font-size: 13px;
font-weight: 500;">
Submit
</button>
</form>
<p class="newsletter_text">
Enter your number/name and click on submit ....
</p>
</div>
</div>
</div>
</div>
目前内容将向左对齐,但我希望它与中心对齐,那么我如何使用引导程序来做到这一点?
解决方案
Bootstrap 4 有实用程序类来实现这一点,因此请尝试使用以下justify-content-center
类row
:
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-4 col-md-6 col-lg-4">
<div class="footer_widget">
<h3 class="footer_title">
Enter your number
</h3>
<form asp-action="Search" method="get" class="newsletter_form">
<input type="text" name="number" placeholder="Enter your number" style="height: 50px;background: #fff;padding-left: 20px;font-size: 15px;color: #000;border: 1px solid #596672;border-radius: 30px;width: 100%;">
<button type="submit" style="position: absolute;height: 40px; border: none;color: #fff;background: #2EBDBE; padding: 0 22px; cursor: pointer; border-radius: 30px; top: 5px; right: 5px; font-size: 13px; font-weight: 500;">
Submit
</button>
</form>
<p class="newsletter_text">
Enter your number/name and click on submit ....
</p>
</div>
</div>
</div>
</div>
希望能帮助到你
推荐阅读
- java - Java - WebSocket 在侦听器之外获取响应
- arrays - JSON对象按键数组
- excel - 如何在时间范围内删除行(日期和时间格式,但我只想保留特定时间之间的行)
- angular - 如何在 Angular 6 中使用打字稿显示后备路线?
- json - python json.load 在两个不同的系统上执行不同
- jquery - 在滚动时更改背景颜色
- c - 如何使用 Flex/Bison 求解算术表达式
- python-3.x - 在python中获取给定数字列表中的一对数字的函数
- ruby-on-rails - 使用 Carrierwave 将多张照片上传到 Cloudinary 只会上传一张照片
- gulp - Gulp 加载本地保存的 qunit