• css3实战版的点击列表项产生水波纹动画


    1、html+js:

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <link rel="stylesheet" href="./css/reset.css"/>
        <link rel="stylesheet" href="./css/animation.css"/>
        <script type="text/javascript" src="./js/jquery-1.10.2.min.js"></script>
        <title>animation-css3动画</title>
    </head>
    <body>
    <ul class="clear">
        <li><span class="circle"></span><a href="#">Button</a></li>
        <li><span class="circle"></span><a href="#">Elements</a></li>
        <li><span class="circle"></span><a href="#">Forms</a></li>
        <li><span class="circle"></span><a href="#">Charts</a></li>
    </ul>
    </body>
    <script type="text/javascript">
    ;(function(){
        var items = document.getElementsByTagName('li');
        for(var i = 0; i < items.length; i++){
            items[i].onclick = function(){
    //            alert($(this));
                this.getElementsByTagName('span')[0].style.animation = 'circle-opacity 0.5s linear 0s 1';
                this.getElementsByTagName('span')[0].style.webkitAnimation = 'circle-opacity 0.5s linear 0s 1';
                this.getElementsByTagName('span')[0].style.animationFillMode = 'forwards';
                $(this).siblings().children('a').css('color','#333');
                $(this).children('a').css('color',' #2196f3');
                clearAnimation(this);

                //alert(this.getElementsByTagName('span')[0].getAttribute('class'));//弹出circle证明获取到了子元素span
            }
        }
        function clearAnimation(self){
            var sid = window.setInterval(function(){
                self.getElementsByTagName('span')[0].style.animation = '';
                self.getElementsByTagName('span')[0].style.webkitAnimation = '';
                self.getElementsByTagName('span')[0].style.animationFillMode = '';
                sid = window.clearInterval(sid);
            },500);

        }
    })(window);
    </script>
    </html>

    2、css:

    ul{ 300px;border: red;}
    ul li{ 300px;height: 70px;line-height: 70px;background: #fff;text-align: center;cursor: pointer;overflow: hidden;}
    ul li a{font-weight: 900;}
    ul li:hover a{
        color: #2196f3!important;
        /*animation: circle-opacity 0.5s linear 0s 1;*/
        /*-webkit-animation-fill-mode:forwards;让动画停在最后是这个属性,*/
        /*animation-fill-mode:forwards;*/
    }
    ul li a{position: relative;left: -50px;color: #333;top: -30px;}
    .circle{background: transparent;border-radius: 50%; 70px;height: 70px;display: inline-block;margin: 0 auto;}

    @keyframes circle-opacity{
        0% {
            background: rgba(192,225,250,0);
        }
        50% {
            transform:scale(4);
            background: rgba(192,225,250,1);
        }
        100% {
            transform:scale(16);
            background: rgba(192,225,250,0);
        }
    }
    @-webkit-keyframes circle-opacity{
        0% {
            background: rgba(192,225,250,0);
        }
        50% {
            transform:scale(4);
            background: rgba(192,225,250,1);
        }
        100% {
            transform:scale(16);
            background: rgba(192,225,250,0);
        }
    }

  • 相关阅读:
    ultraEdit使用utf8乱码的解决办法
    利用替换字符串的函数StringReplace删除字符串中指定的字符或字符串
    COBID,CanID,NodeID的不同
    随机生成一个10位的数字(来自大富翁)
    Delphi2010下,Unit aliases会影响到Code Insight功能?
    使用鼠标拖曳的方式移动、更改panel控件的大小
    将四个BYTE数值转换成IEEE754标准的浮点数
    判断shift,ctrl,alt键是否按下
    获取邮箱中的用户名
    IFM控制器中关于支线长度的说明
  • 原文地址:https://www.cnblogs.com/koleyang/p/5481165.html
Copyright © 2020-2023  润新知