我正在尝试将图像旁边的垂直标题文字对齐。我的问题是当我减小窗口宽度和文本换行(高度高于图像高度)时,它开始对齐到图像的顶部
.half {
width: 50%;
}
h4 {
font-size: 40px;
}
<div class="half">
<div class="advantages_header">
<img class="advantages_icon" src="http://placehold.it/90x90" />
<h4>HEADER TEXT MAYBE LONG</h4>
</div>
</div>
答案 0 :(得分:1)
哦!我自己想通了,感谢阅读,我希望它会帮助别人:)
.half {
width: 50%;
}
.advantages_header {
position: relative;
height: 90px;
}
h4 {
left: 110px;
margin-right: 110px;
font-size: 40px;
position: relative;
top: 50%;
transform: translate(0, -50%);
}
img {
position: absolute;
top: 50%;
transform: translate(0, -50%);
}
<div class="half">
<div class="advantages_header">
<img class="advantages_icon" src="http://placehold.it/90x90" />
<h4>HEADER TEXT MAYBE LONG</h4>
</div>
</div>