zoukankan      html  css  js  c++  java
  • 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);
        }
    }

  • 相关阅读:
    关于git你日常工作中会用到的一些东西
    require.context
    vue-cli3.0 使用postcss-plugin-px2rem(推荐)和 postcss-pxtorem(postcss-px2rem)自动转换px为rem 的配置方法;
    div实现富文本编辑框
    webpack-bundle-analyzer打包文件分析工具
    web页面调用支付宝支付
    ajax回调中window.open弹出的窗口会被浏览器拦截的解决方法
    Django 文件上传
    Django 序列化 前端通过ajax来获取数据库中的数据
    Django Form组件 基于源码的扩展
  • 原文地址:https://www.cnblogs.com/koleyang/p/5481165.html
Copyright © 2011-2022 走看看