利用css样式表做一个旋转写轮眼

利用css样式表做一个旋转写轮眼

成品效果图
在这里插入图片描述
首先分析效果图
图中有红色背景圈和里面的三个椭圆和最中心的黑圈组成。
因此,我们应该写一个大的div盒子,来装这三个椭圆div,里面的三个椭圆div和圆的画法类似。

可以用以下代码实现:

        width: 200px;
        height: 200px;
        border-radius:100% 0% 100% 0%;
        border: black 2px solid;        

注意:
这里除了两个斜着的椭圆div,还需要画一个竖着的椭圆div,我们可以利用图形的变形操作,将椭圆沿着Z轴旋转45度。

    **用以下代码实现**
   transform: rotateZ(45deg);

关键帧动画写旋转动画
首先写剧本,写每个时间段图片的旋转位置,然后在需要旋转的div下导入这个剧本
代码如下

写剧本代码
@keyframes xly{
        0%{
            transform: rotate(0deg);
        }
        100%{
            transform: rotate(360deg);
        }
    }
    导入剧本代码
            animation: xly 2s linear infinite;

整个程序的代码如下

在这里插入代码片
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
        .father{
        margin: 100px auto;
        width: 283px;
        border-radius: 50%;
        background-color: red;
        border: 2px solid red;
        height: 283px;
        position: relative;
        animation: xly 2s linear infinite;
    }
    .father:hover{
            animation-play-state: paused;
        }
    .son1{
        width: 200px;
        height: 200px;
        border-radius:100% 0% 100% 0%;
        border: black 2px solid;
        margin: 0 auto;
        position: absolute;
        left: 40px;
        top: 40px;

    }
    .son2{
        width: 200px;
        height: 200px;
        border-radius:0% 100% 0% 100%;
        border: black 2px solid;
        margin: 0 auto;
        position: absolute;
        left: 40px;
        top: 40px;
    }
    .son3{
        width: 200px;
        height: 200px;
        border-radius:100% 0% 100% 0%;
        border: black 2px solid;
        transform: rotateZ(45deg);
        margin: 0 auto;
        position: absolute;
        left: 40px;
        top: 40px;
    }
    .son4{
        width: 200px;
        height: 200px;
        border-radius:0% 100% 0% 100%;
        border: black 2px solid;
        transform: rotateZ(45deg);
        margin: 0 auto;
        position: absolute;
        left: 40px;
        top: 40px;
    }
    .son5{
        width: 50px;
        height: 50px;
        background-color: black;
        border-radius: 50%;
        position: absolute;
        left: 115px;
        top: 115px;
    }
    @keyframes xly{
        0%{
            transform: rotate(0deg);
        }
        100%{
            transform: rotate(360deg);
        }
    }
</style>
<body>
    <div class="father">
        <div class="son1"></div>
        <div class="son2"></div>
        <div class="son3"></div>
        <div class="son4"></div>
        <div class="son5"></div>
    </div>
</body>
</html>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值