简体   繁体   English

Internet Explorer 10忽略图像的宽度和高度

[英]Internet Explorer 10 ignores width & height on images

I have a website in which Internet Explorer 10 is completely ignoring the explicitly set width and height attributes in favour of the actual image size. 我有一个网站,其中Internet Explorer 10完全忽略显式设置的宽度和高度属性,而不是实际的图像大小。

The image is defined as: 图像定义为:

<img style="float: left; margin: 0px 10px 0px 0px; display: inline;" 
     align="left" src="http://blog.hinshelwood.com/files/2012/09/metro-findings.png"
     width="64" 
     height="64"/>

But it is rendered as 128x128 in IE10. 但它在IE10中呈现为128x128。 In Chrome it is just as you would expect. 在Chrome中,它就像您期望的那样。

Eg http://blog.hinshelwood.com/tfs-integration-tools-issue-tfs-wit-invalid-submission-conflict-type/ 例如http://blog.hinshelwood.com/tfs-integration-tools-issue-tfs-wit-invalid-submission-conflict-type/

On this page the "Applies To", "Solution" and "Findings" images are all set to 64x64 but in IE10 they display as 128x128. 在此页面上,“适用于”,“解决方案”和“查找”图像都设置为64x64,但在IE10中它们显示为128x128。 I have tried setting the following CSS, but this too is ignored: 我尝试过设置以下CSS,但这也被忽略了:

h3 img {
 width: 64px;
 height: 64px;
}

Does anyone have any ideas why? 有没有人有任何想法?

You have 你有

body .content img {
  max-width: 100%;
  height: auto;
  width: auto \9;
}

http://blog.hinshelwood.com/wp-content/themes/pagelines/pagelines-compiled-css-2_1348178943/ http://blog.hinshelwood.com/wp-content/themes/pagelines/pagelines-compiled-css-2_1348178943/

In IE, the invalid width: auto \\9; 在IE中,无效width: auto \\9; is interpreted as width: auto; 被解释为width: auto;

In Chrome, the invalid width is ignored. 在Chrome中,忽略无效宽度。

Without the width auto, the behaviour of the image is different: 没有宽度自动,图像的行为是不同的:

In Chrome, the width is now derived from h3 IMG { width: 64px; } 在Chrome中,宽度现在来自h3 IMG { width: 64px; } h3 IMG { width: 64px; } , and since the height is auto, the image is scaled according to 64px. h3 IMG { width: 64px; } ,并且由于高度是自动,图像被根据64PX缩放。

In IE, both width and height are still "auto", and thus it takes on the default IMG sizes. 在IE中,宽度和高度仍然是“自动”,因此它采用默认的IMG大小。

CSS styles overrides IMG tag attributes : you can try using inline styling to override inherited styles. CSS样式会覆盖IMG标记属性 :您可以尝试使用内联样式来覆盖继承的样式。

<img style="height: 64px; width: 64px;" src="..." />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM