首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bootstrap(css):如何在页面中心布局登录表单

bootstrap(css):如何在页面中心布局登录表单
EN

Stack Overflow用户
提问于 2018-06-03 10:58:00
回答 1查看 1K关注 0票数 0

现在登录表单在左侧布局。

。我想在中间布局,我已经尝试了一些css样式,但是失败了。当我删除代码中的'{% extends "common/base.html“%}‘时,表单可以放在中间,尽管没有css样式和导航栏。

我的html代码如下,我已经添加了css样式。

代码语言:javascript
复制
{% extends "common/base.html" %}    
{% block content %}
<div class="main-login", id="parent">
<form align="center" action="/login" method="POST" >
    <div class="login-screen">
        <div class="app-title">
            <h1>Login</h1>
        </div>
        <div class="login-form">
            <div class="control-group">
            <input type="text" class="login-field" value="" placeholder="username" name="username">
            <label class="login-field-icon fui-user" for="login-name"></label>
            </div>
            <div class="control-group">
            <input type="password" class="login-field" value="" placeholder="password" name="password">
            <label class="login-field-icon fui-lock" for="login-pass"></label>
            </div>
            <input type="submit" value="Log in" class="btn btn-primary btn-large btn-block" >
            <br>
    <p>{{ _('New User?') }} <a href="{{ url_for('auth.register') }}">{{ _('Click to Register!') }}</a></p>
    <p>
        {{ _('Forgot Your Password?') }}
        <a href="{{ url_for('auth.reset_password_request') }}">{{ _('Click to Reset It') }}</a>
    </p>
        </div>
    </div>
</form>
 </div>]

我的css代码:

代码语言:javascript
复制
    .main-login{
  padding-top: 100px;
  text-align: center;
  width:500px;
  /*align-items: center;*/
  vertical-align: middle;
}

     #parent {
   /*display: table;*/
   width: 50%;
   vertical-align: middle;
   text-align: center;

}
.login {
margin: 20px auto;
width: 300px;
}
.login-screen {
/*background-color: #FFF;*/
padding-top: 1000px;
background-color: #3498DB;
padding: 20px;
border-radius: 5px;
text-align: center;

}

.app-title {
text-align: center;
color: #777;
}

.login-form {
text-align: center;
}
.control-group {
margin-bottom: 10px;
}

input {
text-align: center;
background-color: #ECF0F1;
border: 2px solid transparent;
border-radius: 3px;
font-size: 16px;
font-weight: 200;
padding: 10px 0;
width: 250px;
transition: border .5s;
}

input:focus {
border: 2px solid #3498DB;
box-shadow: none;
}

.btn {
  border: 2px solid transparent;
  background: #3498DB;
  color: #ffffff;
  font-size: 16px;
  line-height: 25px;
  padding: 10px 0;
  text-decoration: none;
  text-shadow: none;
  border-radius: 3px;
  box-shadow: none;
  transition: 0.25s;
  display: block;
  width: 250px;
  margin: 0 auto;
}

.btn:hover {
  background-color: #2980B9;
}

.login-link {
  font-size: 12px;
  color: #444;
  display: block;
    margin-top: 12px;
}

在使用vsevolodts的答案后,中间的图像我想使下面的登录按钮的长度与密码表单相同:

EN

回答 1

Stack Overflow用户

发布于 2018-06-03 11:07:25

将下一个CSS技巧应用于主块:

代码语言:javascript
复制
margin-left:auto;
margin-right:auto;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50662909

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档