作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
加载 Facebook SDK 后,我的 CSS 动画在 IE11 中出现故障。
这是一个测试用例:http://tremby.net/dump/ie11test.html
单击按钮会切换其上的一个类,该类通过 CSS 动画稍微旋转按钮。五秒后 Facebook SDK 就会加载。在 Firefox、Chrome 和 IE10 上,按钮在此之后继续工作,但在 IE11 上,添加类后动画将不再播放。
我无法在 JSFiddle 中重现该问题。
知道是什么原因造成的吗? IE11 或 Facebook 的 SDK 一定有问题,但我需要找到解决方法。
这很可能与 Facebook share button breaking CSS animations in IE11 有关看起来非常相似。
最佳答案
我正要将此作为一个错误发布在 Facebook 错误跟踪器上,发现它已经在那里报告了,但尚未修复:
这与 Facebook 使用 document.createStyleSheet
有关,而 IE11 中不再存在此功能。
可以对该函数进行多重填充来解决该问题。可以在https://gist.github.com/harriha/7778849#comment-966352找到对我有用的polyfill。如下:
(function() {
// A polyfill for createStyleSheet() which isn't present in IE11 anymore.
// This makes the current Facebook JS SDK to work so that it won't kick
// IE11 out of the "responsive mode" (= @-ms-viewport still works).
// Note: this should actually return a CSSStyleSheet object, but this
// works as well here as long as at least the el is returned.
document.createStyleSheet = document.createStyleSheet || function(url) {
var el = document.createElement("style");
el.href = url;
document.getElementsByTagName("head")[0].appendChild(el);
return el;
};
})();
关于javascript - 在 IE11 中加载 Facebook SDK 会破坏 CSS 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24543541/
我是一名优秀的程序员,十分优秀!