css - 我的 CSS 幻灯片无法在 Firefox 或 IE11 上运行

标签 css

我是 CSS 的新手,我开始修改我在网上找到的纯 CSS 图像幻灯片(还不知道 javascript)。

它在 webkit 浏览器上完美运行,但是当涉及到 IE11 或 Firefox 时,它根本无法运行。我把代码贴在这里:

http://jsfiddle.net/Ye6Lv/1/

我的猜测是我需要对这段 CSS 做一些 FF/IE11 特定的事情:

/* ANIMATION */
@-moz-keyframes cycle {
    0%  { top:0px; }
    4%  { top:0px; } 
    16% { top:0px; opacity:1; z-index:0; } 
    20% { top:450px; opacity:0; z-index:0; } 
    21% { top:-450px; opacity:0; z-index:-1; }
    92% { top:-450px; opacity:0; z-index:0; }
    96% { top:-450px; opacity:0; }
    100%{ top:0px; opacity:1; }
}

如果有人可以告诉我如何让它在 FF/IE11 上运行(如果可能)。

谢谢。

最佳答案

您对浏览器供应商标签的看法是正确的,您还需要添加官方 CSS 实现 @keyframes(IE 只会听这个)。

这是用代码 http://jsfiddle.net/Ye6Lv/3/ 更新的 fiddle (在 IE11 中测试工作)

例如:

/* ANIMATION */
@-moz-keyframes cycle {
    0%  { top:0px; }
    4%  { top:0px; } 
    16% { top:0px; opacity:1; z-index:0; } 
    20% { top:450px; opacity:0; z-index:0; } 
    21% { top:-450px; opacity:0; z-index:-1; }
    92% { top:-450px; opacity:0; z-index:0; }
    96% { top:-450px; opacity:0; }
    100%{ top:0px; opacity:1; }
}
@-webkit-keyframes cycle {
    0%  { top:0px; }
    4%  { top:0px; } 
    16% { top:0px; opacity:1; z-index:0; } 
    20% { top:450px; opacity:0; z-index:0; } 
    21% { top:-450px; opacity:0; z-index:-1; }
    92% { top:-450px; opacity:0; z-index:0; }
    96% { top:-450px; opacity:0; }
    100%{ top:0px; opacity:1; }
}
@keyframes cycle {
    0%  { top:0px; }
    4%  { top:0px; } 
    16% { top:0px; opacity:1; z-index:0; } 
    20% { top:450px; opacity:0; z-index:0; } 
    21% { top:-450px; opacity:0; z-index:-1; }
    92% { top:-450px; opacity:0; z-index:0; }
    96% { top:-450px; opacity:0; }
    100%{ top:0px; opacity:1; }
}

并且您还需要定义不带浏览器供应商标签的动画。例如:

#slider li.fourthanimation {
    -moz-animation:cyclefour 75s linear infinite;
    -webkit-animation:cyclefour 75s linear infinite;
    animation:cyclefour 75s linear infinite; /* Define the CSS without browser vendor tag */
}

关于css - 我的 CSS 幻灯片无法在 Firefox 或 IE11 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22087471/

相关文章:

html - 鼠标悬停在图像上时显示文本

html - 为所有查看网站的用户设置和更改 css

html - Angular 功能区 CSS

jquery - 在 jQuery 中获取 CSS 规则的百分比值

php - 一个 CSS 类与另一个 CSS 类重叠(附图)

javascript - 为什么这个 SVG 径向进度(循环百分比)不起作用?

javascript - 隐藏元素问题

html - css 旋转 <input> 标签增加了 td 中的空间

html - 50% 宽度框的响应式设计

css - href 因悬停过渡而移动