0
我看到了有關Flexbox的垂直拉伸圖像,並應用對齊自這樣的問題:中心修復它: Why does flexbox stretch my image?如何防止flexbox水平拉伸我的圖像?
不過,我有一個問題,我的圖像水平拉伸: https://jsfiddle.net/qnnpxskk/
HTML:
<div class="wrapper">
<div class="inner">
<div class="row">
<img src="https://www.wired.com/wp-content/uploads/2015/11/google-tensor-flow-logo-F.jpg">
</div>
<div class="row">
<img src="https://www.wired.com/wp-content/uploads/2015/11/google-tensor-flow-logo-F.jpg">
</div>
</div>
</div>
CSS:
.wrapper{
width: 600px;
height: 900px;
background: white;
}
.inner{
display: flex;
flex-direction: column;
}
.row{
max-height: 100px;
margin: 20px;
display: flex;
flex-direction: row;
background: red;
}
.row img{
max-height: 100%;
}
我所嘗試的一切我似乎無法讓圖像不被拉伸。我希望圖像爲父級的100%高度,並保持原始寬高比。
您需要一個用於IE/Edge的polyfill https://github.com/constancecchen/object-fit-polyfill – Gerard