Html 无法将井定位到中心

Html 无法将井定位到中心,html,css,twitter-bootstrap-3,Html,Css,Twitter Bootstrap 3,我正试着把一口井放在页面中心。这方面也有类似的问题,但代码与我的有所不同。我的HTML如下所示: <div class="container"> <div class="row"> <div class="well col-sm-4" align="center"> <div class="text-center">

我正试着把一口井放在页面中心。这方面也有类似的问题,但代码与我的有所不同。我的HTML如下所示:

        <div class="container">
            <div class="row">
                <div class="well col-sm-4" align="center">
                    <div class="text-center">
                        <p><h2>Login</h2></p>
                    </div>
                    <hr>
                    <form role="form">
                        <div class="form-group text-center">   
                            <label for="username">Username</label>
                            <input type="text" class="form-control" id="username">
                        </div>
                        <div class="form-group text-center">
                            <label for="password">Password</label>
                            <input type="password" class="form-control" id="password">
                        </div>
                        <hr>
                        <div class="text-center">
                            <button type="submit" class="btn btn-primary">Submit</button>
                            <button type="button" class="btn btn-warning">Forgot password</button>
                        </div>
                        <hr>
                        <div class="text-center">
                            <p>Don't have an account yet? <a>Create one now</a></p>
                        </div>
                     </form>   
                </div>
            </div>
        </div>

登录


用户名 密码
提交 忘记密码
你还没有账户吗?现在创建一个

我试着将井段放在另一个具有col-md-12和其他值的井段中,但井段没有居中。有人知道我怎么把井放在页面的中心吗?

你可以试试

为您的列指定类别
col-sm-offset-4

像这样:


示例:

您可以放置两个虚拟div,以使您的图像居中。我注意到您只有一个
col-sm-4

试试这个:

<div class = "col-sm-4"></div>
<div class = "well col-sm-4">
<!-- your content here -->
</div>
<div class = "col-sm-4"></div>

要使您的计算机完全集中在桌面视图1280px及更高版本上。

只需在此处替换代码:

 <div class="well col-sm-4" align="center">

使用此选项(您还可以在CSS类中隔离样式):



登录


用户名 密码
提交 忘记密码
你还没有账户吗?现在创建一个


谢谢您的帮助!
 <div class="well col-sm-4" align="center">
<div class="well col-sm-4" style="margin:auto; float:none;">
<div class="container">
            <div class="row">
                <div class="col-sm-4 well col-sm-offset-4" align="center">
                    <div class="text-center">
                        <p><h2>Login</h2></p>
                    </div>
                    <hr>
                    <form role="form">
                        <div class="form-group text-center">   
                            <label for="username">Username</label>
                            <input type="text" class="form-control" id="username">
                        </div>
                        <div class="form-group text-center">
                            <label for="password">Password</label>
                            <input type="password" class="form-control" id="password">
                        </div>
                        <hr>
                        <div class="text-center">
                            <button type="submit" class="btn btn-primary">Submit</button>
                            <button type="button" class="btn btn-warning">Forgot password</button>
                        </div>
                        <hr>
                        <div class="text-center">
                            <p>Don't have an account yet? <a>Create one now</a></p>
                        </div>
                     </form>   
                </div>
            </div>
        </div>