在Bootstrap框架中,图像调整大小在IE8中无法工作

4

我一直在Google和Stackoverflow上搜索,希望能找到与我的问题相关的解决方案,但没有找到:

我正在使用Bootstrap(Twitter)版本2.0,发现在IE8上无法调整图像大小,但在其他浏览器上可以。

调整图像大小的原始代码如下:

 <img src="alpha1-stamp.png" width="70" height="70">

它在Safari、Firefox和Google Chrome等浏览器中呈现得非常好,但在IE8中却不行(我在另一台桌面电脑上只有这个版本,但认为它不应该适用于所有IE版本)。
请给予建议,急需解决这个IE噩梦。
干杯。
6个回答

2

好的,最终我解决了问题,并找到了修改bootstrap.css文件的方法。

只需在bootstrap.css(bootstrap框架)中注释以下内容即可:

/*
img {
  width: auto\9;
  height: auto;
  max-width: 100%;
  vertical-align: middle;
  border: 0;
  -ms-interpolation-mode: bicubic;
} */

1

只需在bootstrap.css(Bootstrap框架)上添加以下注释

img {
  width: auto\9;
  height: auto;
 /* max-width: 100%;*/
  vertical-align: middle;
  border: 0;
  -ms-interpolation-mode: bicubic;
}

0

我遇到了一个问题,Internet Explorer < 8不尊重我的img标签的宽度和高度属性,我能够通过仅删除img选择器中的height:auto规则来解决它。(删除max-width没有帮助)


0
问题出在这里:
width: auto\9; height: auto; 如果你注释掉这一行,在IE上就能正常工作了。

0

0

我通过在 HTML 中使用条件覆盖样式的方式来解决了这个问题。

我已经在 bootstrap 样式表下面添加了一个 IE8 解决方案部分,因此我为有问题的图片添加了重置:

<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" />

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <style type="text/css">
      img, img.img-responsive {
     width:auto;
     height:auto;
     max-width: none;
      }
    </style>

<![endif]-->
<style type="text/css">

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接