文本在面板标题中不是一直居中的?

时间:2017-04-24 01:16:46

标签: html css twitter-bootstrap

我正在为网站制作一个登录表单。

我正在尝试将一些文本放在表单上的面板标题中,但它不是一直居中的。

// starts here
tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() { 
    @Override 
    public void changed(ObservableValue<? extends Tab> observable, Tab oldTab, Tab newTab) {
        if(newTab.equals (total)) {            
            System.out.print(total.isSelected());
        }
    }
});
/*
------Sign up------
*/

body {
  padding-top: 90px;
}

.panel-login {
  border-color: #ccc;
  -webkit-box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.2);
  -moz-box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.2);
  box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.2);
}

.panel-login>.panel-heading {
  color: #00415d;
  background-color: #fff;
  border-color: #fff;
  text-align: right;
  width: 100%;
}

.panel-login>.panel-heading a {
  text-decoration: none;
  color: #666;
  font-weight: bold;
  font-size: 15px;
  -webkit-transition: all 0.1s linear;
  -moz-transition: all 0.1s linear;
  transition: all 0.1s linear;
}

.panel-login>.panel-heading a.active {
  color: #5C67B6;
  font-size: 18px;
}

.panel-login>.panel-heading hr {
  margin-top: 10px;
  margin-bottom: 0px;
  clear: both;
  border: 0;
  height: 1px;
  background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0));
  background-image: -moz-linear-gradient(left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0));
  background-image: -ms-linear-gradient(left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0));
  background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0));
}

.panel-login input[type="text"],
.panel-login input[type="email"],
.panel-login input[type="password"] {
  height: 45px;
  border: 1px solid #ddd;
  font-size: 16px;
  -webkit-transition: all 0.1s linear;
  -moz-transition: all 0.1s linear;
  transition: all 0.1s linear;
}

.panel-login input:hover,
.panel-login input:focus {
  outline: none;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
  border-color: #ccc;
}

.btn-login {
  background-color: #59B2E0;
  outline: none;
  color: #fff;
  font-size: 14px;
  height: auto;
  font-weight: normal;
  padding: 14px 0;
  text-transform: uppercase;
  border-color: #59B2E6;
}

.btn-login:hover,
.btn-login:focus {
  color: #fff;
  background-color: #53A3CD;
  border-color: #53A3CD;
}

.forgot-password {
  text-decoration: underline;
  color: #888;
}

.forgot-password:hover,
.forgot-password:focus {
  text-decoration: underline;
  color: #666;
}

.btn-register {
  background-color: #53A3CD;
  outline: none;
  color: #fff;
  font-size: 14px;
  height: auto;
  font-weight: normal;
  padding: 14px 0;
  text-transform: uppercase;
  border-color: #53A3CD;
}

.btn-register:hover,
.btn-register:focus {
  color: #fff;
  background-color: #419ccc;
  border-color: #419ccc;
}

.main-center {
  margin-top: 30px;
  margin: 0 auto;
  max-width: 330px;
  padding: 40px 40px;
  background-color: #fff;
}

.login-button {
  margin-top: 5px;
}

.login-register {
  font-size: 11px;
  text-align: center;
}

正如你所看到的,如果你放大它,它只会在一点点卡在左侧。我希望它完全集中。

如何在此面板标题中居中文字?

4 个答案:

答案 0 :(得分:3)

尝试将小提琴中的第7行更改为以下内容:

<div class="col-xs-12 text-center">

https://jsfiddle.net/v3zzyyxu/

答案 1 :(得分:1)

将.col-xs-6更改为.col-xs-12并添加样式属性

text-align: center;

以下是fiddle

答案 2 :(得分:0)

这里看看这个 https://jsfiddle.net/qj4pem5L/2/

<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <div class="panel panel-login">
                <div class="panel-heading">
                    <div class="row">                   
                        <div class="col-xs-12 col-sm-12 text-center">
                            <a href="#login" class="active" id="login-form-link">Login</a>
                        </div>                      
                    </div>
                    <hr>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-12">                         

                          <form id="login-form" action="#login" method="post" role="form" style="display: block;">
                                <div class="form-group">
                                    <input type="text" name="username" id="username" tabindex="1" class="form-control" placeholder="Username" value="">
                                </div>
                                <div class="form-group">
                                    <input type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="Password">
                                </div>
                                <div class="form-group text-center">
                                    <input type="checkbox" tabindex="3" class="" name="remember" id="remember">
                                    <label for="remember"> Remember Me</label>
                                </div>
                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-sm-6 col-sm-offset-3">
                                            <input type="submit" name="login-submit" id="login-submit" tabindex="4" class="form-control btn btn-login" value="Log In">
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <div class="text-center">
                                                <a href="#" tabindex="5" class="forgot-password">Forgot Password?</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                 </div>
            </div>
       </div>
    </div>

更新了您的代码! 只需轻触课程即可#34;文字中心&#34;! :)

答案 3 :(得分:0)

尝试像这样做

<div style="text-align:center">
    <a href="#login" class="active" id="login-form-link">Login</a>
</div>

enter image description here