微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jquery – Bootstrap Center水平对齐div

我尝试过简单的登录页面.但是我无法将这些字段对齐到中心位置. h:commandButton与中心对齐.但保持< div align =“center”>时,其余的字段都没有任何变化.

我如何让它们居中对齐?

<div align="center">            
    <h:message for="btnSubmit"/>
    <div class='form-row'>
        <div class='col-xs-2 form-group required'>
         <label class='control-label'> User Name </label>
          <h:inputText styleClass="form-control" size="12" maxlength="20" 
                       id="userName" value="#{loginController.userName}" 
                       required="true"/>
        </div>
    </div>

    <div class='form-row'>
        <div class='col-xs-2 form-group card required'>
           <label class='control-label'>Password</label>
           <h:inputText styleClass="form-control" size="12" maxlength="20"
                        id="password" value="#{loginController.password}"
                        required="true" />
         </div>
    </div>

    <div class='form-row'>
        div class='col-md-12 form-group'>
      <h:commandButton styleClass="btn btn-success" 
               value="#{bundle['label.Login']}" id="btnSubmit" 
               action="#{loginController.clientLoginAction}"/>
        </div>
    </div>
</div>

解决方法

最简单的方法是从您身边添加一个自定义类.col-center
.col-center{
  margin:0 auto;
}

为什么这样?因为BS有偏移的方法,但它有一个缺点,因为它只适用于偶数列大小,所以只有.col-X-2,.col-X-4,col-X-6,col-X-8和col -X-10受支持.

必须这样做:只要确保你想要居中的div,有一个提到的div宽度….. col-center将完成剩余的工作

原文地址:https://www.jb51.cc/jquery/178683.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐