首页 > 其他分享 >css3动画次数限制

css3动画次数限制

时间:2022-10-26 16:35:37浏览次数:57  
标签:css3 动画 iteration count 次数 state animation webkit

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
<style> 
div
{
    width:100px;
    height:100px;
    background:red;
    position:relative;
    animation:mymove 3s;
    animation-iteration-count:3;

    /* Safari and Chrome */
    -webkit-animation:mymove 3s;
    -webkit-animation-iteration-count:3;
}

@keyframes mymove
{
    from {top:0px;}
    to {top:200px;}
}

@-webkit-keyframes mymove /* Safari and Chrome */
{
    from {top:0px;}
    to {top:200px;}
}
</style>
</head>
<body>

<p><strong>注意:</strong> Internet Explorer 9 及更早 IE 版本浏览器不支持 animation-iteration-count 属性。</p>

<div></div>

</body>
</html>

css3动画不循环可以使用animation-iteration-count属性定义动画的播放次数。

只需要在动画中添加“animation-iteration-count:infinite;”或者不写,即可实现无限次循环。
animation-iteration-count :n;定义动画的播放n次。

.state {
    position: absolute; bottom: 65px; right: 180px; z-index: 100000000;
}

.state p {
    padding: 5px 50px 5px 20px;
    font-size: 13px;
    color: #333;
    font-weight: bold;
    border-radius: 25px;
}

.state.into p {
    background: #999;
}

.state.out p {
    background: #FF5465;
}

.state {
    opacity: 0;
    animation: animate2 2s ease-in-out infinite;
    -webkit-animation: animate2 2s ease-in-out infinite;
    animation-iteration-count:1;
    -webkit-animation-iteration-count:1;
}

@keyframes animate2 {
    0% {
        bottom: 65px;
    }

    30% {
        bottom: 95px;
        opacity: 1;
    }

    70% {
        bottom: 135px;
        opacity: 0.8;
    }

    100% {
        bottom: 170px;
        opacity: 0;
    }
}
<div class="state">
    <p>走你!</p>
</div>

 

标签:css3,动画,iteration,count,次数,state,animation,webkit
From: https://www.cnblogs.com/luckyuns/p/16828900.html

相关文章