我在div中有一个按钮,当前位于div的顶部。我想将它垂直居中于iths parent div。
.button-login {
background-color: white;
border: 2px solid #01BDE0;
border-radius: 4px;
color:#01BDE0;
width: 100%;
height:46px;
vertical-align: middle;
font-size: 1vw;
display: block;
}
这是按钮的CSS。
<div class=" pure-u-1 pure-u-md-2-24"><button class="button-login">LOG IN</button></div>
这是html部分。
我试过垂直对齐它不起作用。
答案 0 :(得分:0)
试试这个...
<style>
.pure-u-1 { width:100%;}
.center {height: 500px; background-color: #222;}
.vertical-align {position: relative; top: 50%; transform: translateY(-50%); }
</style>
<div class=" pure-u-1 pure-u-md-2-24">
<div class="center" align="center">
<div class="vertical-align">
<button class="button-login">LOG IN</button>
</div>
</div>
</div>
答案 1 :(得分:0)
.video-contant {
position: absolute;
background: rgba(7, 7, 7, 0.52);
width: 100%;
top: 0px;
height: 100%;
display: table;
}
.hctr {
display: table-cell;
vertical-align: middle;
text-align: center;
color: #fff;
width: 100%;
overflow: hidden;
}
&#13;
<div class="video-contant">
<div class="hctr">
<button>onewebbell.com<button>
</div>
</div>
&#13;