【发布时间】:2021-03-03 13:01:22
【问题描述】:
我有 4 行不同的两列,一列有图片,另一列有文本。由于文本和图像的大小不同,我希望它们垂直居中。
这是我的其中一列的代码和该 div 的 CSS
.col2 {
float: left;
width: 46%;
padding: 2%;
text-align: center;
position: relative;
justify-content: center;
height: 300px;
}
<div class="col2">
<img src="images/freelance.png" alt="three people watching a presentation">
</div>
<div class="col2">
<h2>Work as a Freelancer</h2>
<p>This session will set out the key points you need
to consider when taking on freelance work in order to make
sure you gain maximum professional and personal benefit.</p>
<div class="book">
<a class="booked" href="#" target="_blank"><p><b>Book 14th March 6pm</b></p></a>
</div>
</div>
【问题讨论】: