如何对齐中间div以使两条线垂直居中?
.container {
display: flex;
justify-content: space-between;
align-items: center;
}
.second {
text-align: left;
flex-grow: 2;
}
img {
margin-right: 20px;
}
<div class="container">
<div>
<img src="http://via.placeholder.com/75x75">
</div>
<div class="second">
<h2>Please vertically center both</h2>
<p>of us!</p>
</div>
<div>
Right
</div>
</div>
答案 0 :(得分:1)
添加Global Variable
以移除为h2,p{margin:0}
和h2
代码
p
.container {
display: flex;
justify-content: space-between;
align-items: center;
}
.second {
text-align: left;
flex-grow: 2;
}
img {
margin-right: 20px;
}
h2,p{margin:0}