html - 旋转齿轮 css 在 IE 中不起作用

标签 html css

我有一些用于旋转齿轮的 CSS,到目前为止它们在 Firefox 中运行良好但在 IE 中不起作用。谁能解决这个问题。

这是我引用类的 html:

<div class="gear" id="gear1"></div>
<div class="gear" id="gear2"></div>
<div class="gear" id="gear3"></div>
<div class="gear" id="gear4"></div>
<div class="gear" id="gear5"></div>
<div class="gear" id="gear6"></div>
<div class="gear" id="gear7"></div>

这是我的CSS:

/* CSS3 keyframes */
@-webkit-keyframes ckw {
    0% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
        -ms-transform: rotate(0deg);
        -o-transform: rotate(0deg);
        transform: rotate(0deg);
    }

    100% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
        -o-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

@-moz-keyframes ckw {
    0% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
        -ms-transform: rotate(0deg);
        -o-transform: rotate(0deg);
        transform: rotate(0deg);
    }

    100% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
        -o-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

@-webkit-keyframes cckw {
    0% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
        -o-transform: rotate(360deg);
        transform: rotate(360deg);
    }

    100% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
        -ms-transform: rotate(0deg);
        -o-transform: rotate(0deg);
        transform: rotate(0deg);
    }
}

@-moz-keyframes cckw {
    0% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
        -o-transform: rotate(360deg);
        transform: rotate(360deg);
    }

    100% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
        -ms-transform: rotate(0deg);
        -o-transform: rotate(0deg);
        transform: rotate(0deg);
    }
}

@keyframes cckw {
    0% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
        -o-transform: rotate(360deg);
        transform: rotate(360deg);
    }

    100% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
        -ms-transform: rotate(0deg);
        -o-transform: rotate(0deg);
        transform: rotate(0deg);
    }
}

/* gears */
.gear {
    float: none;
    position: absolute;
    text-align: center;
    -moz-animation-timing-function: linear;
    -moz-animation-iteration-count: infinite;
    -moz-animation-direction: normal;
    -o-animation-direction: normal;
    -moz-animation-delay: 0;
    -o-animation-delay: 0;
    -moz-animation-play-state: running;
    -moz-animation-fill-mode: forwards;
    -webkit-animation-timing-function: linear;
    -o-animation-timing-function: linear;
    animation-timing-function: linear;
    -webkit-animation-iteration-count: infinite;
    -o-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    -webkit-animation-direction: normal;
    animation-direction: normal;
    -webkit-animation-delay: 0;
    animation-delay: 0;
    -webkit-animation-play-state: running;
    -o-animation-play-state: running;
    animation-play-state: running;
    -webkit-animation-fill-mode: forwards;
    -o-animation-fill-mode: forwards;
    animation-fill-mode: forwards;
}

#gear1 {
    background: url('g1.png') no-repeat 0 0;
    height: 85px;
    left: 31px;
    top: 45px;
    width: 85px;
    -moz-animation-name: ckw;
    -moz-animation-duration: 10s;
    -webkit-animation-name: ckw;
    -o-animation-name: ckw;
    animation-name: ckw;
    -webkit-animation-duration: 10s;
    -o-animation-duration: 10s;
    animation-duration: 10s;
}

#gear2 {
    background: url('g2.png') no-repeat 0 0;
    height: 125px;
    left: 105px;
    top: 10px;
    width: 125px;
    -moz-animation-name: cckw;
    -moz-animation-duration: 16.84s;
    -webkit-animation-name: cckw;
    -o-animation-name: cckw;
    animation-name: cckw;
    -webkit-animation-duration: 16.84s;
    -o-animation-duration: 16.84s;
    animation-duration: 16.84s;
}

#gear3 {
    background: url('g3.png') no-repeat 0 0;
    height: 103px;
    left: 149px;
    top: 118px;
    width: 103px;
    -moz-animation-name: ckw;
    -moz-animation-duration: 13.5s;
    -webkit-animation-name: ckw;
    -o-animation-name: ckw;
    animation-name: ckw;
    -webkit-animation-duration: 13.5s;
    -o-animation-duration: 13.5s;
    animation-duration: 13.5s;
}

#gear4 {
    background: url('g4.png') no-repeat 0 0;
    height: 144px;
    left: 46px;
    top: 173px;
    width: 144px;
    -moz-animation-name: cckw;
    -moz-animation-duration: 20.2s;
    -webkit-animation-name: cckw;
    -o-animation-name: cckw;
    animation-name: cckw;
    -webkit-animation-duration: 20.2s;
    -o-animation-duration: 20.2s;
    animation-duration: 20.2s;
}

#gear5 {
    background: url('g1.png') no-repeat 0 0;
    height: 85px;
    left: 127px;
    top: 292px;
    width: 85px;
    -moz-animation-name: ckw;
    -moz-animation-duration: 10s;
    -webkit-animation-name: ckw;
    -o-animation-name: ckw;
    animation-name: ckw;
    -webkit-animation-duration: 10s;
    -o-animation-duration: 10s;
    animation-duration: 10s;
}

#gear6 {
    background: url('g2.png') no-repeat 0 0;
    height: 125px;
    left: 200px;
    top: 283px;
    width: 125px;
    -moz-animation-name: cckw;
    -moz-animation-duration: 16.84s;
    -webkit-animation-name: cckw;
    -o-animation-name: cckw;
    animation-name: cckw;
    -webkit-animation-duration: 16.84s;
    -o-animation-duration: 16.84s;
    animation-duration: 16.84s;
}

#gear7 {
    background: url('g3.png') no-repeat 0 0;
    height: 103px;
    left: 277px;
    top: 217px;
    width: 103px;
    -moz-animation-name: ckw;
    -moz-animation-duration: 13.5s;
    -webkit-animation-name: ckw;
    -o-animation-name: ckw;
    animation-name: ckw;
    -webkit-animation-duration: 13.5s;
    -o-animation-duration: 13.5s;
    animation-duration: 13.5s;
}

最佳答案

如果您使用的是 IE 10 之前的版本,关键帧动画将无法使用。参见 Caniuse兼容性表,如果您需要旧版浏览器支持,请考虑使用 JavaScript/jQuery 替代方案或 polyfill。

编辑:看起来您的某些 CSS(即您的 .gear 类)缺少 -ms 前缀,这将为您提供更广泛的兼容性。

关于html - 旋转齿轮 css 在 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21296767/

相关文章:

css - 用 CSS(特别是 Bootstrap)的话说,什么是 "well"?

html - 应用 CSS 网格时 Owl Carousel 2 不工作

html - 如何对齐 HTML 中的两列

JavaScript - 按类获取 div 中的文本

css - 表格没有清除自己的默认值?

javascript - HTML5/Javascript 游戏开发 - 如果我有多个边界,则只有最新的边界有效

javascript - 如何使用相同的 createElement 变量多次使用 appendChild

jquery - 从 3 ul 获取最大 li 高度并将其添加到所有

javascript - 如何停止裁剪 IE 中 Textarea 的最后一行并降低行高?

jquery - IE10和IE11中不同的animate.css动画