【问题标题】:Background-size-polyfill does not work in IE8?Background-size-polyfill 在 IE8 中不起作用?
【发布时间】:2014-08-16 07:37:27
【问题描述】:

我有这个简单的代码:

<html style = "height: 100%;">
    <head>
        <meta http-equiv = 'Content-Type' content = 'text/html; charset = windows-1251' />
        <title>test bg</title>
    </head>

    <body style = "height: 100%; margin: 0px;">
        <div id = 'div_0' style = "width: 100%; height: 100%; background-size: contain; -ms-behavior: url(backgroundsize.htc); background-repeat: no-repeat; background-position: center center; background-image: url(storage/zast_800x600.jpg);"></div>
    </body>
</html>

页面加载时没有任何错误。但是背景的行为和没有这个东西一样。

.htaccessbackgroundsize.htc 与 html 页面位于同一文件夹中。我通过双击 html 页面在本地运行此文件。

我使用 PolyFill 作为参考

【问题讨论】:

  • 是的,试试上面的编辑,看看它是否有效
  • @Richa - 没有任何效果。仍然没有任何错误。
  • 能否给个demo页面或者工作demo

标签: html css internet-explorer-8 background-size


【解决方案1】:

.htaccess 不会在您的 Windows 文件系统中执行任何操作,例如将具有正确 MIME 类型的文件提供给 IE,这是 .htc 文件执行任何操作所必需的。您需要将它放在正在运行的 Apache 服务器中;它是服务器要执行的指令列表。

如果您无法访问开发服务器或其他已建立的服务器,您可以尝试WAMP 或其他让本地 Apache 服务器运行的方法。

原来真正的答案是在其他地方的 GitHub 上找到的。提问者没有在标准模式下运行,导致ms-behavior: 声明失败; Quirks 模式仅识别 behavior:

【讨论】:

  • 然后,我不知道如何,但是包中的 index.html 页面以这种方式工作。我通过双击从文件夹启动它,并在 IE8 中正确调整图像大小。
猜你喜欢
  • 1970-01-01
  • 2021-05-15
  • 1970-01-01
  • 1970-01-01
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-07
相关资源
最近更新 更多