[英]Constrain and image max-width to parent container and re-scal height doesn't work in IE11
我有下面的代碼。
我想強制圖像max-width
被約束/重新縮放到容器 width ,並且高度是自由的。 它適用於 Chrome/Firefox,但不適用於 IE11
.cimage { -ms-flex-align: center; align-items: center; border: 1px solid red; display: -ms-flexbox; display: flex; -ms-flex-negative: 0; flex-shrink: 0; -ms-flex-positive: 0; flex-grow: 0; -ms-flex-pack: center; justify-content: center; padding: .75rem; width: 5.5rem; } .cimage img { max-width: 100%; min-width:1px; }
<div class="cimage"> <a href="/"> <img src="https://via.placeholder.com/250x150"> </a> </div>
IE截圖:
添加flex: 1
或min-width: 1px
到flex item - a
元素,以在 IE11 中修復此問題。 請參閱下面的演示:
.cimage { -ms-flex-align: center; align-items: center; border: 1px solid red; display: -ms-flexbox; display: flex; -ms-flex-negative: 0; flex-shrink: 0; -ms-flex-positive: 0; flex-grow: 0; -ms-flex-pack: center; justify-content: center; padding: .75rem; width: 5.5rem; } .cimage img { max-width: 100%; min-width:1px; } .cimage a { /* ADDED */ flex: 1; }
<div class="cimage"> <a href="/"> <img src="https://via.placeholder.com/250x150"> </a> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.