【发布时间】:2020-08-24 22:13:30
【问题描述】:
我正在尝试构建一个小型 ToDo 应用程序。我试图将input 字段和提交按钮放在中心,但对齐到左侧。
#todo {
align-items: center;
text-align: center;
}
#todo .form-group {
align-items: center;
margin: auto;
}
#id-button {
margin: 10px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js">
<div id="todo">
<p>
<h3>Add New ToDo</h3>
<div class="form-group">
<div class="col-xs-4">
<input type="text" class="form-control" placeholder="Add New ToDo Item">
<button id="id-button" type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
有什么建议吗?
【问题讨论】:
-
您的示例将它们放在中心,或者?你什么意思
-
@ajobi,检查底部的我的 JSFiddle 链接。