我想將我的div與我的頁面中心的一些登錄信息對齊。它適用於靜態值,但我想動態定位它。另外,背景應該覆蓋整個頁面,但它只是涵蓋了與我的div的高度帶...如何在整頁面背景的頁面中心放置Div
這裏是我的代碼:
.bold{
\t font-weight: bold
}
#login {
\t width: 300px;
\t margin-left: auto;
margin-right: auto;
margin-top: 15%;
background-color: white;
border-style: outset; <!--Just there to show the border-->
}
.background {
\t background-color: #f5f5f0;
\t min-height: 100%;
\t height: auto !important;
}
<div class=background> \t
\t <div class="well well-lg" id="login">
\t \t <h2>LOGIN</h2>
\t \t <form method="post" ng-submit="login()">
\t \t \t <input name="username" type="text" ng-model="username" placeholder="username"><br>
\t \t \t <input name="password" type="password" ng-model="password" placeholder="password"><br>
\t \t \t <input type="submit" value="Einloggen">
\t \t </form>
\t </div>
</div>
https://css-tricks.com/centering-css-complete-guide/,https://css-tricks.com/centering-in-the-unknown/ – CBroe