-2
堆疊的div我有以下的代碼,垂直居中我的內容使用Flex
HTML
<div class="titleHide flex">
<h4>...</h4>
<h1>...</h1>
</div>
CSS
.titleHide {
position: absolute;
top: 0; left: 0;
height: 100%; width: 100%;
background-color: rgba(209,30,93,0.8);
}
.flex {
display: flex;
flex: 1;
align-items: center;
}
.flex被其他的div我的網站上。然而,在這種情況下,它將h1和h4標題放在一起,我希望它們在彼此之上。