正如你在演示中看到的那樣,一旦我添加了<em>
,<button>
就被取代了。我如何垂直居中父母的兩個元素?
我想button
垂直中心在footer
。
演示:http://jsfiddle.net/chovy/5h5hc/1/
HTML
<footer>
<button class="btn-primary">Reply</button>
</footer>
<footer>
<em></em>
<button class="btn-primary">Reply</button>
</footer>
CSS
footer {
display: block;
height: 50px;
line-height: 50px;
border: 1px solid red;
padding: 0 20px;
text-align: right;
margin-top: 20px;
}
em {
display: inline-block;
height: 50px;
width: 50px;
border: 1px solid blue;
box-sizing: border-box;
}
您只添加空間。但在你的演示回覆按鈕沒有得到vertical-align – falguni
適合我。謝謝。我想知道是否有一種方法可以用css添加空間。我不喜歡必須記住把' '放在那裏。 – chovy