做一个有天有地的css及html画的旋转阴阳鱼

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>天地阴阳</title>
    <style>
        /* 重置默认样式 */
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        /* 基础布局 */
        html, body {
            height: 100%;
        }

        .container {
            height: 100%;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        /* 天地背景 */
        .sky {
            flex: 1;
            background: linear-gradient(to bottom, #87CEEB, #E0F6FF);
        }

        .earth {
            height: 50%;
            background: linear-gradient(to bottom, #90EE90, #228B22);
        }

        /* 八卦图主容器 */
        .box {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 300px;
            height: 300px;
            border-radius: 50%;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
            animation: rotate 8s linear infinite;
            transform-origin: center center;
            backdrop-filter: blur(5px);
            /* 移除重复的样式定义和背景色 */
        }

        /* 阴阳鱼左右半圆 */
        .semi-circle {
            position: absolute;
            height: 100%;
            width: 50%;
        }

        .left {
            left: 0;
            background: #000;
            border-radius: 150px 0 0 150px;
            width: 50%;
        }

        .right {
            right: 0;
            background: #fff;
            border-radius: 0 150px 150px 0;
            width: 50%;
        }

        /* 在box容器中添加背景色 */
        .box {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 300px;
            height: 300px;
            border-radius: 50%;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
            animation: rotate 8s linear infinite;
            transform-origin: center center;
            backdrop-filter: blur(5px);
            background: rgba(255, 255, 255, 0.8);  /* 添加背景色 */
        }

        /* 阴阳鱼大圆 */
        .circle {
            position: absolute;
            left: 25%;
            width: 50%;
            height: 50%;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .top-circle {
            top: 0;
            background: #000;  /* 改为纯黑色 */
        }

        .bottom-circle {
            bottom: 0;
            background: #fff;  /* 改为纯白色 */
        }

        /* 阴阳眼 */
        .small-circle {
            width: 30px;
            height: 30px;
            border-radius: 50%;
        }

        .white { background: #fff; }  /* 改为纯白色 */
        .black { background: #000; }  /* 改为纯黑色 */

        /* 旋转动画 */
        @keyframes rotate {
            from { transform: translate(-50%, -50%) rotate(0deg); }
            to { transform: translate(-50%, -50%) rotate(360deg); }
        }

        /* 悬停效果 */
        .box:hover {
            animation-play-state: paused;
            box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sky"></div>
        <div class="earth"></div>
        <div class="box">
            <div class="semi-circle left"></div>
            <div class="semi-circle right"></div>
            <div class="circle top-circle">
                <span class="small-circle white"></span>
            </div>
            <div class="circle bottom-circle">
                <span class="small-circle black"></span>
            </div>
        </div>
    </div>
</body>
</html>
相关推荐
bug爱好者1 分钟前
原生小程序如何实现跨页面传值
前端·javascript
bug爱好者10 分钟前
原生微信小程序最实用的工具函数合集
前端·javascript
3Katrina13 分钟前
JS事件机制详解(2)--- 委托机制、事件应用
前端·javascript·面试
Allen Bright19 分钟前
【CSS-15】深入理解CSS transition-duration:掌握过渡动画的时长控制
前端·css
code_YuJun33 分钟前
从内存角度理解JS代码执行过程
javascript
DoraBigHead1 小时前
【JS三兄弟谁是谁】搞懂 splice、slice、split,只需一杯奶茶的时间!
前端·javascript·面试
国家不保护废物1 小时前
前端存储与后端服务的奇妙冒险:一个Node.js服务器的诞生记(cookie实现用户登入)
前端·javascript·后端
前端付豪1 小时前
2、前端架构三要素:模块化、工程化、平台化
前端·javascript·架构
WildBlue1 小时前
流式输出:前端工程师的魔术表演,小白也能看懂!🎩✨
前端·javascript·node.js
多啦C梦a1 小时前
React 事件机制大揭秘:从 addEventListener 到合成事件,别再一脸懵逼!
前端·javascript