我已經閱讀了至少5篇有關此問題的文章,以及文章like thisand this。這一定是可能的!使用CSS在身體內垂直居中DIV
我在我的身體內有一個div,我想垂直居中在我的頁面上。就像這樣:
<body>
<div>I would like this to appear in the middle of the viewport.</div>
</body>
第二條上面展示了其解決方案,但他們的例子是其他的div,它不適合你想要一個體內中心的DIV裏面工作的div。我曾嘗試在div中設置div,並將高度設置爲100%,但這隻會讓我的瀏覽器生氣。
請幫忙!我不想訴諸JQuery!
http://stackoverflow.com/questions/12771982/vertically-centering-a-div-in-body和http://stackoverflow.com/questions/396145/how-to-vertically-center-a-div-for-全部瀏覽器 –
謝謝@ Mohamed-Yous如果第一個人做了這個訣竅。可惜我無法將你的答案標記爲解決方案。 – serlingpa
我希望如此:) :) ..祝你好運:-) –