html - 居中表单和输入
问题描述
我一直在尝试将我的表单和输入水平居中,但它不起作用
我试过使用边距和填充,但没有任何效果。
body {
background-color: #2F2F2F;
}
/* Form (outside) */
.form-inline {
padding: 1% 0%;
}
/* Input (inside) */
.form-control {
background-color: #353434;
border: #3E3E3E 2px solid;
/* Top right bottom left */
/* Align the writing in the center*/
text-align: center;
}
/* Search text */
.form-control::placeholder {
color: #AEAEAE;
text-align: center;
}
<header>
<!-- Search inputForm -->
<div class="container">
<form class="form-inline my-2 my-lg-0" action="#POST">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
</form>
</div>
</header>
解决方案
.container {
display: flex;
}
form {
margin: 0 auto;
}
推荐阅读
- javascript - slack botkit - 特定斜杠命令上的“听到”不起作用
- javascript - Ember 仅在初始渲染时调用 jQuery 代码
- r - R:从列表中查找所有元素并将结果写入另一个列表
- swift - 以编程方式添加更改 Tableview 行的按钮
- java - 如何使用 Hibernate 在实体中创建属性表?
- javascript - 我如何在反应钩子中编写“setTimeOut”函数?
- javascript - 如何将 SAR 报告提取到 Excel
- html - 如何不重叠不规则表格上的任何边框?
- angular - 角茉莉花找到挂计时器
- c++ - 为什么 std::copyable 包含 std::movable?