CSS3怎么实现点击放大的动画

这篇文章主要介绍了CSS3怎么实现点击放大的动画的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇CSS3怎么实现点击放大的动画文章都会有所收获,下面我们一起来看看吧。

示例代码

<!DOCTYPE html>
<head>
       <style type="text/css">
        @keyframes myfirst {
            0% {
                width: 50px;
                height: 50px;
                top: 10px;
                right: 10px;
            }
            75% {
                width: 60px;
                height: 60px;
                top: 5px;
                right: 5px;
            }
            100% {
                width: 50px;
                height: 50px;
                top: 10px;
                right: 10px;
            }
        }
        .warp {
            width: 400px;
            height: 300px;
            position: relative;
            background: #ccc;
        }
        .btn {
            position: absolute;
            width: 50px;
            height: 50px;
            border:solid 3px #cc3c24;
            top: 10px;
            right: 10px;
            border-radius: 8px;
            cursor: pointer;
        }
        .btn.cur{
            animation: myfirst 0.2s;
        }
        .btn.yes{
            background: #cc3c24;
        }
    </style>
</head>
<body>
<div class="warp">
    <div class="btn"></div>
</div>
<script src="http://liuxiaofan.com/demo/js/jquery-2.1.4.min.js"></script>
<script>
   var btn = $('.btn');
    btn.click(function () {
        if( $(this).is('.yes')){
            $(this).removeClass('yes');
            $(this).removeClass('cur');
        }else{
            $(this).addClass('yes');
            $(this).addClass('cur');
        }
    });
    btn.on('webkitAnimationEnd', function () {
        $(this).removeClass('cur');
    });
</script>
</body>
</html>

效果图如下:

CSS3怎么实现点击放大的动画

CSS3怎么实现点击放大的动画

关于“CSS3怎么实现点击放大的动画”这篇文章内容就介绍到这里,感谢各位的阅读!相信大家对“CSS3怎么实现点击放大的动画”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注编程之家行业资讯频道。

相关文章

蚂蚁庄园小课堂2024年6月29日答案是什么?进入支付宝一起饲养...
谷歌小恐龙怎么调出来,我们将连接电脑的网络拔掉或者禁用网...
蚂蚁庄园小课堂2024年6月22日答案是什么?每天蚂蚁庄园小课堂...
火绒为什么不建议大家用,火绒对于用户的要求比较高,查杀病...
百度网盘电脑版订阅的分享在哪?百度网盘电脑版订阅的分享在什...
notepad怎么替换换行符,打开notepad++软件,点击菜单栏的视...