CSS3动画在IE / Edge上不同步

时间:2018-10-12 22:41:34

标签: html css css3 internet-explorer css-animations

我在一个元素上运行了一个简单的动画,该动画使用绝对定位使“星形”元素从一个地方移动到另一个地方。在移动到下一个位置之前,它会使用不透明度短暂地淡入和淡出,然后重复。这在Chrome和Firefox中可以正常工作,但是IE / Edge当然存在问题。最好在这里看到:Codepen

问题::在IE / Edge中,动画在第一次迭代中可以正确运行,但是一旦动画开始循环播放,不透明度和绝对位置的变化就会与“星标”正在淡入/淡出,但不应该这样。 Chrome显示了理想的动画步骤:淡入,淡出,移动,停止,重复。

代码如下:

@import url(https://fonts.googleapis.com/css?family=Mr+Dafoe);
@-webkit-keyframes star-effect {
    0% {
        left: -7%;
        top: 44%;
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    10% {
        left: -7%;
        top: 44%;
        opacity: 0;
    }
    35% {
        left: 44%;
        top: 0%;
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
    45% {
        left: 44%;
        top: 0%;
        opacity: 0;
    }
    70% {
        left: 90%;
        top: 6%;
        opacity: 0;
    }
    75% {
        opacity: 1;
    }
    80% {
        left: 90%;
        top: 6%;
        opacity: 0;
    }
    100% {
        left: -7%;
        top: 44%;
        opacity: 0;
    }
}
body{
    background: #000;
    margin: 0;
    padding: 50px;
    font-size: 16px;
    width: 100%;
    font-family: "Helvetica Neue",helvetica,Arial,sans-serif;
    overflow-x: hidden;
}
h1{
    position: relative;
    height: 1.35em;
    line-height: 1;
    font-size: 10rem;
    margin: 0;
    transition: font-size .2s linear;
}
h1 > span:nth-child(1){
    position: absolute;
    padding-left: 30px;
    padding-right: 50px;
    top: 0px;
    font-family: 'Mr Dafoe', cursive;
    font-size: .87em;
    margin-top: 0px;
    margin-bottom: 0;
    color: #fd5afa;
    text-shadow: -2px -2px 0 #FFBAF2;
    -webkit-filter: drop-shadow(3px 3px 1px #441F62);
    -webkit-transform: skew(-5deg,-5deg);
    font-weight: normal;
    z-index: 2;
    -webkit-backface-visibility: hidden;
}
h1 span.star{
    position: absolute;
    display: block;
    left: -7%;
    top: 44%;
    width: 80px;
    height: 80px;
    z-index: 4;
    opacity: 0;
    -webkit-animation-name: star-effect;
            animation-name: star-effect;
    -webkit-animation-duration: 6s;
            animation-duration: 6s;
    -webkit-animation-timing-function: linear;
            animation-timing-function: linear;
    -webkit-animation-iteration-count: infinite;
            animation-iteration-count: infinite;
}
h1 span.star:before{
    position: absolute;
    content: '';
    background-image: -webkit-radial-gradient(#fff 20%, transparent 80%);
    width: 100%;
    height: 2px;
    display: block;
    top: 50%;
}
h1 span.star:after{
    position: absolute;
    content: '';
    background-image: -webkit-radial-gradient(#fff 0%, transparent 90%);
    width: 2px;
    height: 100%;
    display: block;
    left: 50%;
}
<body>
  <h1>
    <span>Word<span class="star"></span></span>
  </h1>
</body>

0 个答案:

没有答案