PictureFill无法在Internet Explorer中运行; 不承认srcset?

amy*_*n83 3 html css internet-explorer picturefill

我已经使用Picturefill在我的网页上加载了几张图片.它们在Chrome中正确显示,但在Internet Explorer 8中根本不显示.

以下是我的代码示例:

<link href="styles.css" rel="stylesheet" type="text/css">
<script src="js/modernizr.custom.11641.js"></script>
<script async="true" src="js/picturefill.js"></script>
<script src="js/respond.js"></script>
</head>

<body>
<div class="wrapper">
    <header class="x-padding inside-b-padding">
        <h1 class="nocontent outline">Baseball for Busy
        People</h1>


    <picture class="logo">
        <!--[if IE 9]><video style="display: none;"><![endif]-->
        <source srcset="images/logo.png" media="(min-width: 750px)">
        <!--[if IE 9]></video><![endif]-->
        <img srcset="images/logo-small.png" alt="Baseball for Busy People">
    </picture> 
Run Code Online (Sandbox Code Playgroud)

(我包括顶部,以防我的文件链接是问题的一部分).

我可以在IE 8中查看演示:http://scottjehl.github.io/picturefill/examples/demo-02.html.但是我页面上的图像不起作用.

这是我尝试过的:

  1. 我将演示中的代码复制并粘贴到我的页面中(将图像路径更改为绝对路径) - 它们没有显示.
  2. 我添加了脚本来创建一个<picture>元素(虽然我使用的是Modernizr,所以不需要它).
  3. 我添加了一个src路径到img标签,这有用,但我读到Picturefill不推荐这个.

小智 6

我知道很久以前就问过这个问题,但也许这会帮助遇到类似问题的其他人.我有同样的问题,PictureFill图像没有加载到我的网站上的浏览器本身不支持它(例如IE9 - IE11).修复是为了确保在将元素添加到页面时调用picturefill()(我在Angular中的指令中调用它,在React中调用componentDidMount).