使用css做一个旋转的八卦图

使用css做一个旋转的八卦图

1, html部分

html 复制代码
<div class="tai">
 	<div class="bai"></div>
    <div class="hei"></div>
</div>

2, css部分

css 复制代码
.tai{
        width: 200px;
        height: 200px;
        border: 1px solid #000;
        background: linear-gradient(#fff 50%, #000 50%); // 使用渐变添加背景颜色
        border-radius: 50%;
        display: flex;
        align-items: center;

        .bai{
            height: 50%;
            width: 50%;
            background: #fff;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        // 白色部分黑色小圆点
        .bai::after{
            content: '';
            width: 30px;
            height: 30px;
            background: #000;
            border-radius: 50%;
        }

        .hei{
            height: 50%;
            width: 50%;
            background: #000;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        黑色部分白色小圆点
        .hei::after{
            content: '';
            width: 30px;
            height: 30px;
            background: #fff;
            border-radius: 50%;
        }

        // 加个动画旋转起来
        animation: rotate 2s linear infinite;
    }

    @keyframes rotate {
        from{
            transform: rotate(0deg);
        }
        to{
            transform: rotate(360deg);
        }
    }
相关推荐
拖拉斯旋风13 分钟前
防抖(Debounce)实战解析:如何用闭包优化频繁 AJAX 请求,提升用户体验
前端
老前端的功夫21 分钟前
TypeScript 全局类型声明:declare关键字的深度解析与实战
linux·前端·javascript·ubuntu·typescript·前端框架
golang学习记23 分钟前
VS Code 1.107 发布:AI 不再是插件,而是编辑器的「第一大脑」
前端
EndingCoder35 分钟前
TypeScript 入门:理解其本质与价值
前端·javascript·ubuntu·typescript·node.js
1024小神35 分钟前
cloudflare使用express实现api防止跨域cors
前端
we1less40 分钟前
[audio] AudioTrack (七) 播放流程分析
前端
Johnnyhaha1 小时前
Docker Compose Pull 超时与代理踩坑记录
前端
烟袅1 小时前
React 表单的控制欲:什么时候我们真得控制它了,什么时候该放养了?
前端·react.js
不想秃头的程序员1 小时前
吃透 JS 事件委托:从原理到实战,解锁高性能事件处理方案
前端·面试
AntoineGriezmann1 小时前
前端 Token 刷新机制实战:基于 Axios 的 accessToken 自动续期方案
前端