[英]HTML: Vertical align div in div
我想將一個div垂直居中放置在另一個div中,但無法正常工作。 圖像div需要在父div(黑色)div中居中。 我已經嘗試過
position: absolute;
修復,以及
display: table-cell;
但它們似乎都不起作用。 問題似乎是我的父級div是100%。有人可以幫助我嗎? 示例在這里:
<div style="display: table; height: 800px; #position: relative; overflow: hidden;">
<div style=" #position: absolute; #top: 50%;display: table-cell; vertical-align: middle;">
<div class="greenBorder" style=" #position: relative; #top: -50%">
any text<br />
any content<br /><br /><br />
everything is vertically centered
</div>
</div>
</div>
參見: http : //jsfiddle.net/9eDXM/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.