首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何强制Internet Explorer11正确显示图像纵横比?

如何强制Internet Explorer11正确显示图像纵横比?
EN

Stack Overflow用户
提问于 2019-01-05 17:57:46
回答 2查看 2K关注 0票数 3

如果你使用Internet Explorer11查看this page,你可以看到图像的纵横比不正确-图像被垂直拉伸。IE11顽固地显示图像的原始高度。所有其他浏览器(最新的Chrome、Firefox和Edge版本)都能正确显示。为什么这个css代码不能与IE 11一起工作?

html:

代码语言:javascript
复制
<section class="content-6 sec-content">
<div class="container sec-right">
<div>
<img src="https://eoy.ee/oosorr/images/8.jpg" alt="Nõmmemännik" width="1280" height="853" />
</div>
</div>
</section>

css:

代码语言:javascript
复制
img {
width:100%;
height:auto;
max-width: 100%;
}

.sec-content{
display:-ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction:column;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-pack: end;
justify-content: flex-end;
}

.sec-content > div{
padding-bottom:50px;
display:-ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction:row;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}

.sec-right{
-ms-flex-pack: end;
justify-content: flex-end;
}

.sec-right > div{
display:-ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction:column;
padding:35px 45px;
position: relative;
z-index: 10;
width: 90%;
}

.sec-right > div::before {
background: rgba(0,0,0,0.4);
content:" ";
top:0;
bottom:0;
width:3000px;
position: absolute;
z-index: -100;
}

.sec-right > div::before {
left: 0;
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-01-06 01:48:46

根据this discussion的说法,IE flexbox的实现似乎存在一个错误,可以通过将以下代码添加到你的图像样式中来解决这个问题。

代码语言:javascript
复制
img {
    ...
    min-height: 1px;
}
票数 7
EN

Stack Overflow用户

发布于 2019-01-06 19:14:32

Piotr链接非常有用- min-height:1px solved the problem.它没有帮助然后我将它添加到img,但添加到.sec-content > div。我删除了一些flexbox属性。最终css:

代码语言:javascript
复制
.sec-content{
display:-ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction:column;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-pack: end;
justify-content: flex-end;
}

.sec-content > div{
padding-bottom:50px;
display:-ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction:row;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
    min-height: 1px;
}

.sec-right{
-ms-flex-pack: end;
justify-content: flex-end;
}

.sec-right > div{
padding:35px 45px;
position: relative;
z-index: 10;
width: 100%;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54050865

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档