【问题标题】:make a panel form in the center of the page在页面中心制作一个面板表单
【发布时间】:2013-12-05 19:01:19
【问题描述】:

所以我试图创建一个带有 Twitter Bootstrap 的表单面板到页面的中心,希望即使浏览器正在调整大小,它仍然在中心, here's 我在 jsfiddle 上尝试过的,问题是我似乎无法使其居中,有人有想法吗?完整代码在下面

<div class="container">
        <div class="row">
            <div class="panel panel-default">
                <div class="panel-body">
                    <legend>User Login</legend>
                    <form role="form">
                        <div class="form-group">
                            <label for="inputEmail">
                                Username</label>
                            <input id="inputEmail" type="text" class="form-control" placeholder="ex: John.Doe"
                                required="" />
                        </div>
                        <div class="form-group">
                            <label for="inputPassword">
                                Password</label>
                            <input id="inputPassword" type="password" class="form-control" placeholder="*******"
                                required="" />
                        </div>
                        <div class="checkbox">
                            <label>
                                <input id="chkRememberMe" type="checkbox" />
                                Remember Me
                            </label>
                        </div>
                        <button id="btnSubmit" type="submit" class="btn navbar-custom">
                            Submit</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

预览:

【问题讨论】:

    标签: asp.net css vb.net twitter-bootstrap-3


    【解决方案1】:

    请更换

    <div class="panel panel-default">
    

    有了这个

    <div class="panel panel-default" style="max-width:400px;margin-left:auto; margin-right:auto;">
    

    【讨论】:

      【解决方案2】:

      尝试在 div 的 style 属性中设置边距:

      style="margin-left:auto;margin-right:auto;"
      

      希望它有效...

      【讨论】:

        【解决方案3】:

        您还可以使用列来调整面板的大小和居中,例如:

        <div class="container">
            <div class="row">
                <div class="col-md-offset-3 col-md-6">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <legend>User Login</legend>
        
                            <form role="form">
                                <div class="form-group">
                                    <label for="inputEmail">Username</label>
                                    <input id="inputEmail" type="text" class="form-control" placeholder="ex: John.Doe" required="" />
                                </div>
        
                                <div class="form-group">
                                    <label for="inputPassword">Password</label>
                                    <input id="inputPassword" type="password" class="form-control" placeholder="*******" required="" />
                                </div>
        
                                <div class="checkbox">
                                    <label>
                                        <input id="chkRememberMe" type="checkbox" />
                                        Remember Me
                                    </label>
                                </div>
        
                                <button id="btnSubmit" type="submit" class="btn navbar-custom">Submit</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        

        【讨论】:

          猜你喜欢
          • 2011-02-20
          • 1970-01-01
          • 2014-06-09
          • 1970-01-01
          • 1970-01-01
          • 2011-10-10
          • 1970-01-01
          • 1970-01-01
          • 2021-10-16
          相关资源
          最近更新 更多