使用CSS,在一个包含图片和文本两列的行中,是否可能使它们的内容垂直居中对齐?
我已经为此苦思冥想了几天,并尝试了我能想到的一切。
这是我正在使用的基本结构,完全基于百分比。这是一个响应式单页布局,基于一系列具有最小高度设置为100%的部分。
CSS
html, body {
width: 100%;
height: 100%;
}
section {
width: 100%;
min-height: 100%;
display:table;
height:inherit;
}
.row {
width: 100%;
height: 100%;
display:table-cell;
}
.col-left, .col-right {
float: left;
width: 50%;
height: 100%;
}
/*--this should be vertically centred--*/
.content {
}
HTML
<section>
<div class="row">
<div class="col-left">
<div class="content">
<h1>SOME TEXT</h1>
</div>
</div>
<div class="col-right">
<div class="content">
<img src="SOME IMAGE URL">
</div>
</div>
</div>
</section>