【问题标题】:Image work fine I Chrome but not IE图像工作正常我 Chrome 但不是 IE
【发布时间】:2018-01-29 08:41:06
【问题描述】:

我的页面右侧有两张并排的图片。它在 Chrome 中完美运行并且显示正确,但在 Internet Edge 中图片非常大。我错过了什么?

代码如下:

text = "<div><center><table style=\"width:100%;\">" +
        "<tbody><tr>" +
        "<td align=\"left\">" +
        "<a href=\"http://www." + test + "/m.aspx\"><center><img style=\"display: block; height: auto;max-width: 95%;margin: 0 auto;\" src=\"/images/" + entryM.Image + "\"></center></a>" +
        "</td>" +
        "<td align=\"right\">" +
        "<a href=\"http://www." + test + "/test/" + entryR.url + "\" target=\"_blank\"><center><img style=\"display: block; height: auto;max-width: 95%;margin: 0 auto;\" src=\"/images/" + 
entryR.Image + "\"></center></a>" +
        "</td> " +
        "</tr>" +
        "<tr>" +
        "<td style=\"text-align:center;\">test</td>" +
        "<td style=\"text-align:center;\">test</td>" +
        "</tr>" +
        "</tbody></table>" +
        "<table style=\"width:100%; margin-bottom: 30px;\">" +
        "<tbody><tr>" +
        "<td style=\"text-align:center;\">" +
        "<a href=\"http://www." + test + "/m.aspx\"><u>test</u></a>" +
        "</td>" +
        "</tr>" +
        "</tbody></table>" +
        "</center></div>";

【问题讨论】:

  • 演示对于查看问题非常有用。我认为表格布局将是解决这个问题的关键......

标签: c# css google-chrome internet-explorer responsive


【解决方案1】:
 @supports (-ms-ime-align:auto) {
  /* edge*/
  .img{
    max-height: 92px;//img height
  }
 }

  @media all and (-ms-high-contrast:none){
    /* ie*/
    .img{
      height: 43px;//img height
    }
  }  

【讨论】:

  • IE 和边缘在弹性框和表格中存在高度问题。他们试图填充容器height: auto 而 IE 不支持 max-height @Koopakiller @Mykremin
【解决方案2】:

尝试在两张图片中添加width: 50%

<img style=\"display: block; height: auto; width: 50%; max-width: 95%;margin: 0 auto;\" src=\"/images/" + entryM.Image + "\">

【讨论】:

  • 还是一样的 :/ 两张图片在 IE 中都很大,但在 Chrome 中效果很好
  • 在这种情况下尝试以 px 为单位给出宽度(例如:250px)
  • 不起作用。我的页面也有响应,所以如果我在 chrome 中缩小窗口,图片也会显示正确。但在 IE 图像中是巨大的
猜你喜欢
  • 2015-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-29
  • 2012-11-27
相关资源
最近更新 更多