CSS动画特效展示

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS动画特效展示</title>
    <style>
        /* 基础样式 */
        body {
            margin: 0;
            padding: 0;
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
            height: 100vh;
            overflow-x: hidden;
            color: white;
        }

        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            text-align: center;
        }

        h1 {
            font-size: 3em;
            margin-bottom: 30px;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        /* 动画盒子 */
        .animation-box {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 30px;
            margin-top: 50px;
        }

        .animation-item {
            width: 200px;
            height: 200px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2em;
            font-weight: bold;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        /* 各种动画效果 */
        .rotate-animation {
            animation: rotate 4s linear infinite;
        }

        @keyframes rotate {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .bounce-animation {
            animation: bounce 2s ease infinite;
        }

        @keyframes bounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-30px); }
        }

        .pulse-animation {
            animation: pulse 1.5s ease infinite;
        }

        .shake-animation {
            animation: shake 0.5s ease infinite;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-10px); }
            75% { transform: translateX(10px); }
        }

        .float-animation {
            animation: float 6s ease-in-out infinite;
        }

        @keyframes float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-20px); }
        }

        .color-change-animation {
            animation: colorChange 8s linear infinite;
        }

        @keyframes colorChange {
            0% { background-color: #ff9a9e; }
            25% { background-color: #fad0c4; }
            50% { background-color: #a18cd1; }
            75% { background-color: #fbc2eb; }
            100% { background-color: #ff9a9e; }
        }

        /* 场景动画 */
        .scene {
            margin-top: 50px;
            height: 300px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 20px;
            position: relative;
            overflow: hidden;
        }

        .sun {
            position: absolute;
            top: 50px;
            left: 100px;
            width: 80px;
            height: 80px;
            background: radial-gradient(circle, #ffde59, #ff914d);
            border-radius: 50%;
            box-shadow: 0 0 50px #ff914d;
            animation: sunRise 10s infinite alternate;
        }

        @keyframes sunRise {
            0% { transform: translateY(150px); opacity: 0; }
            100% { transform: translateY(0); opacity: 1; }
        }

        .cloud {
            position: absolute;
            background: white;
            border-radius: 50%;
            opacity: 0.8;
        }

        .cloud1 {
            width: 60px;
            height: 30px;
            top: 80px;
            left: 300px;
            animation: cloudMove 20s linear infinite;
        }

        .cloud2 {
            width: 100px;
            height: 50px;
            top: 120px;
            left: 500px;
            animation: cloudMove 25s linear infinite reverse;
        }

        @keyframes cloudMove {
            0% { transform: translateX(-100px); }
            100% { transform: translateX(1200px); }
        }

        .ground {
            position: absolute;
            bottom: 0;
            width: 100%;
            height: 100px;
            background: linear-gradient(to top, #5d4037, #8d6e63);
        }

        .tree {
            position: absolute;
            bottom: 100px;
        }

        .trunk {
            width: 20px;
            height: 60px;
            background: #5d4037;
            margin-left: 40px;
        }

        .leaves {
            width: 100px;
            height: 80px;
            background: #2e7d32;
            border-radius: 50px 50px 0 0;
            margin-left: -30px;
            margin-bottom: 10px;
        }

        .tree1 {
            left: 200px;
            animation: treeSway 5s ease-in-out infinite;
        }

        .tree2 {
            left: 400px;
            animation: treeSway 4s ease-in-out infinite reverse;
        }

        .tree3 {
            left: 700px;
            animation: treeSway 6s ease-in-out infinite;
        }

        @keyframes treeSway {
            0%, 100% { transform: rotate(0deg); }
            50% { transform: rotate(5deg); }
        }

        /* 链接样式 */
        .link {
            margin-top: 50px;
            padding: 15px 30px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 50px;
            display: inline-block;
            text-decoration: none;
            color: white;
            font-weight: bold;
            transition: all 0.3s ease;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        .link:hover {
            background: rgba(255, 255, 255, 0.4);
            transform: translateY(-5px);
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .animation-item {
                width: 150px;
                height: 150px;
                font-size: 1em;
            }
            
            h1 {
                font-size: 2em;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>CSS动画特效展示</h1>
        
        <div class="animation-box">
            <div class="animation-item rotate-animation">旋转动画</div>
            <div class="animation-item bounce-animation">弹跳动画</div>
            <div class="animation-item pulse-animation">脉动效果</div>
            <div class="animation-item shake-animation">摇晃效果</div>
            <div class="animation-item float-animation">浮动效果</div>
            <div class="animation-item color-change-animation">颜色变化</div>
        </div>
        
        <div class="scene">
            <div class="sun"></div>
            <div class="cloud cloud1"></div>
            <div class="cloud cloud2"></div>
            
            <div class="ground"></div>
            
            <div class="tree tree1">
                <div class="leaves"></div>
                <div class="trunk"></div>
            </div>
            
            <div class="tree tree2">
                <div class="leaves"></div>
                <div class="trunk"></div>
            </div>
            
            <div class="tree tree3">
                <div class="leaves"></div>
                <div class="trunk"></div>
            </div>
        </div>
        
     
    </div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值