html - Bootstrap 中的中心表单

标签 html css twitter-bootstrap

我在 Bootstrap 中将表单居中时遇到问题。我似乎也无法调整输入框的大小。我想让它居中。

这是我的:

     <div class="form-group row" id="SignupCreate">
      <div class="col-sm-4">
    <label>Email</label>
      <input type="email" class="form-control" id="inputEmail" placeholder="Email">
    </div>

      <div class="col-sm-4">
    <label>Password</label>
      <input type="password" class="form-control" id="inputPassword" placeholder="Password">
  <div class="col-sm-4">
      <button type="submit">Submit</button>
  </div>
    </div>
    </div>

对于 CSS,我开始:

#SignUpCreate {
    padding-top: 200px;
    margin-right: 30px;
    margin-left: 30px;

}

最佳答案

你只需要应用一些宽度并使其居中 margin: 0 auto

<div class="form-group row" id="signupcreate">
        <div class="col-sm-4">
            <label>Email</label>
            <input type="email" class="form-control" id="inputEmail" placeholder="Email">
        </div>
        <div class="col-sm-4">
            <label>Password</label>
            <input type="password" class="form-control" id="inputPassword" placeholder="Password">
        </div>
        <div class="col-sm-4">
            <button type="submit">Submit</button>
        </div>
    </div>

下面的代码将使您的表单居中

#signupcreate{
  width: 60%;
  margin: 0 auto;
  float: none;
}

关于html - Bootstrap 中的中心表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43713851/

相关文章:

html - 有没有办法将内联样式规则传递给所有 child ?

javascript - jQuery - 将 CSS 应用于匹配项

javascript - 弹出框在第一次点击时不显示,但在第二次点击时显示

twitter-bootstrap - 在 Meteor 中使用 handlebars 和 twitter bootstrap 进行 DRY

css - 如何在 Twitter Bootstrap 中实现 "Drag Out Menu"?

javascript - HTML/CSS/JS - 模态弹出窗口的叠加背景 - 问题

php - PHP 文件类型中 HTML 的 Vim 自动缩进不起作用

css - 如何在文章旁边放置图片和分隔线?

html - 图像不会与下拉菜单中的文本对齐

html - 登录表单太大