我希望内容垂直和水平居中,但它只居中水平居中。问题是我没有固定的高度。 谢谢你们的帮助!居中水平和垂直的DIV没有固定高度
html,
body {
height: 100% margin: 0;
overflow: hidden;
}
.content {
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
display: flex;
flex-direction: column;
text-align: center;
}
<div class="content">
<h1>Welcome to the website!</h1>
</div>
你的html在哪里 –
你肯定答案不能在这个线程中找到http://stackoverflow.com/questions/396145/how-to-vertically-center-a-div-for-所有浏览器? – Turnip
谢谢,找到解决方案! – Daniel