简单css3动画效果练习

简单css3动画效果练习

知识点

  • 简单伪元素的使用
  • 布局练习
  • 动画效果练习

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="../reset.css">
    <!-- <link href="https://fonts.googleapis.com/css?family=Bungee" rel="stylesheet"> -->
    <style>
        body {
            background: #ccc;
        }
        .demo {
            height: 200px;
            width: 300px;
            left: calc(50% - 150px);
            top: calc(50% - 100px);
            position: absolute;
            background-color: #333333;
            background: -moz-radial-gradient(rgba(121, 121,121, 0.5) 5%, rgba(51,51,51,0.7) 50%, rgba(0, 0, 0, 0.8));
            border-radius: 10px;
            cursor: pointer;
            text-align: center;
            overflow: hidden;

        }
        .demo span {
            color: #ffffff;
            font-family: 'Bungee', cursive;
            font-size: 25px;
            text-shadow: 2px 1px 1px gray;
            position: relative;
            top:-30px;
            transition: top 0.2s ease;
            -webkit-transition: top 0.2s ease;
            z-index: 10;
        }
        .demo:hover span{
            top:25px;
            transition: top 0.2s ease 0.2s;
            -webkit-transition: top 0.2s ease 0.2s;
        }
        .demo::before {
            content: '';
            height: 40px;
            width: 40px;
            border-radius: 50%;
            background-color: #339966;
            position: absolute;
            top: calc(50% - 20px);
            left: -100px;
            z-index: 1;
        }
        .demo::after {
            content: '';
            height: 30px;
            width: 30px;
            border-radius: 50%;
            background-color: #ff3333;
            position: absolute;
            top: calc(50% - 15px);
            left: 350px;
            z-index: 1;
        }
        @keyframes lefZoom {
            0% {
                left: -100px;
                transform: scale(1);
                background-color: #339966;
                opacity: 1;
            }
            35% {
                left: calc(50% - 20px); 
                transform: scale(1);
                background-color: #339966;
                opacity: 0.8;
            }
            40% {
                left: calc(50% - 10px); 
                transform: scale(1);
                background-color: #993366;
                opacity: 0.5;
            }
            100% {
                left: calc(50% - 5px);
                transform: scale(10);
                background-color: #993366;
                opacity: 0.8;
            }
        }
        @keyframes rigZoom {
            0% {
                left: 350px;
                opacity: 1;
            }
            35% {
                left: calc(50% + 0px);  
                opacity: 0.8;
            }
            40% {
                left: calc(50% - 5px);  
                opacity: 0.5;
            }
            100% {
                left: calc(50% - 5px);
                opacity: 0;
            }
        }
        .demo:hover::before {
            /*left: calc(50% - 20px);
            transition: left 0.2s ease;*/
            animation: lefZoom 0.7s ease 0.1s;
        }
        .demo:hover::after {
            animation: rigZoom 0.7s ease 0.1s;
        }
        .demo:hover {
            background-color: #993366;
            transition: background-color 0.2s ease 0.6s;
        }
    </style>
</head>
<body>
    <div class="demo">
        <span>demo</span>   
    </div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值