答案 0 :(得分:1)
您可以稍微更改HTML布局吗?
.main {
display: table;
height: 100px;
border: solid 1px;
}
.inner {
display:table-cell;
vertical-align:middle
}
.top, .bottom {background:yellow;}
<div class="main">
<div class="inner">
<div class="top">Top</div>
<div class="bottom">Bottom</div>
</div>
</div>
请查看以下内容。
答案 1 :(得分:1)
只需将父级的显示设置为table-cell:
.main {
display: table-cell;
height: 100px;
border: solid 1px;
vertical-align: middle;
}
&#13;
<div class="main">
<div class="top">Top</div>
<div class="bottom">Bottom</div>
</div>
&#13;
答案 2 :(得分:0)
position: relative;
top: 50%;
transform: translateY(-50%);
答案 3 :(得分:0)
HTML:
var updateUserEarnings = function (User,prizeValue){
//var user = new Parse.User();
User.set("cashBalance", User.get("cashBalance")+prizeValue);
CSS:
<div class="main">
<div class="wrapper">
<div class="top">Top</div>
<div class="bottom">Bottom</div>
</div>
</div>