我有一個<h1>
元素和三個寬度爲33%的div。所有這4個元素都在高度設置爲100vh的容器中。垂直中心標題元素和一組使用flexbox的內聯div使用flexbox
目前我可以水平對齊三個div,但是當我插入<h1>
標記時,它將在它們旁邊對齊。
如何將頂部的<h1>
與其下方的三個元素對齊?
.outside {
background-color: red;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.inside {
background-color: yellow;
width: 30%;
margin-left: 1.5%;
margin-right: 1.5%;
float: left;
}
<div class="outside">
<div>
<h1> This is another</h1>
</div>
<div class="inside">
<h1>This is h1 tag</h1>
<p>This is paragraph</p>
</div>
<div class="inside">
<h1>This is h1 tag</h1>
<p>This is paragraph</p>
</div>
<div class="inside">
<h1>This is h1 tag</h1>
<p>This is paragraph</p>
</div>
</div>
Matmik這是我認爲很好,但似乎是它沒有爲我工作 – John
編輯我的回答一點。最主要的是你已經把它構造得有點小了! – matmik