【发布时间】:2019-01-18 06:13:10
【问题描述】:
如何使横向和纵向图像在一个 div 中彼此相邻保持相同的高度? 我在这里做了一个粗略的草图: showing the desired layout
这是我尝试过的代码:
HTML
<div class="image-wrapper">
<div class="image">
<img src="http://placekitten.com/400/600" />
</div>
<div class="image">
<img src="http://placekitten.com/600/400" />
</div>
</div>
CSS
.image-wrapper {
width: 100%;
padding: 1rem;
display: flex;
justify-content: center;
flex-direction: row;
box-sizing: border-box;
max-height: 700px;
background-color: yellow;
}
.image {
background-color: red;
}
.image:first-of-type {
margin-right: 1rem;
}
img {
max-height: 100%;
max-width: 100%;
}
这是一个小提琴:http://jsfiddle.net/8xaqjp6k/18/ 奇怪的是,我的代码,不是小提琴在 Safari 中工作得很好,但在 Chrome 或 Firefox 中却不行
【问题讨论】: