【问题标题】:IE fix for png not workingIE 修复 png 不工作
【发布时间】:2023-03-29 01:40:01
【问题描述】:

有谁知道为什么下面的代码不起作用?我真的很想使用这种方法而不是任何 JavaScript 方法。我也尝试了绝对路径,但没有运气。

.test {
    width: 500px; /* Must Specify Width */
    height: 176px;
    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src='../images/test-bg.png');
}

【问题讨论】:

  • 确保路径是相对于它显示的页面,而不是 CSS 文件。所以你试过 src='/images/test-bg.png' ?

标签: css xhtml internet-explorer-6


【解决方案1】:

我认为sizingMethod=scale 需要是sizingMethod="scale"

【讨论】:

    【解决方案2】:

    我看到您尝试了绝对路径,但您是否尝试过来自域(不包括域)的路径?

    因此,如果完整路径是“http://www.example.co.uk/images/test.png”,您只需使用“/images/test.png”

    这就是我过去使用它的方式

    【讨论】:

      【解决方案3】:

      试试:

      filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/test-bg.png', sizingMethod=scale, enabled="true");

      【讨论】:

        【解决方案4】:

        与 CSS 文件中的其他文件引用不同,filter 属性的 src 属性与浏览器中的 URL 相关。因此,对于您的示例代码,假设图像文件夹位于 http://www.yoursite.com/images 并且您使用的 src../images/test-bg.png

        http://www.yoursite.com/                                -> Doesn't work
        http://www.yoursite.com/some-page/                      -> Works
        http://www.yoursite.com/some-page/another-level-deeper/ -> Doesn't work
        

        最好的方法是使用相对于根的路径,像这样:

        filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/test-bg.png',sizingMethod='scale');

        如果这不是问题,另一种可能性是图像的尺寸可能太小。过去,我发现拉伸 1x1 像素的图像可能会出现问题,并且有时无法正确渲染。在这种情况下,一种解决方法是使用更大的图像(超过 5x5 像素)。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-07-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-05-24
          • 1970-01-01
          相关资源
          最近更新 更多