CSS3——旋转小风车


前言

兴趣是最好的老师。让我们一起在玩闹中学习吧,上次做了一个idol旋转魔方,这次做个旋转风车吧,学以致用,熟能生巧。


提示:以下是本篇文章正文内容,下面案例可供参考

一、知识点

背景线性渐变:

语法:
background:linear-gradient(起始方向,颜色1,颜色2,…);
background:-webkit-linear-gradient(left,red,blue);(兼容性)
background:-webkit-linear-gradient(left top,red,blue);(方向)

二、制作步骤

  1. 首先设置一个300*300大小的盒子box;
  2. 里面装4个小盒子hezi,用于设置隐藏超出盒子的部分;
  3. 最里面分别再装4个span来制作风车的半圆,使用border-radio属性来设置圆角,margin来设置半圆的位置;
  4. 最后就是中间添加一个正方形的固定器;
  5. 风车颜色的部分使用了背景线性渐变来制作的;

三、详细代码

CSS代码如下(示例):


        * {
            margin: 0;
            padding: 0;
        }
        
        .box {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            width: 300px;
            height: 300px;
            margin: 100px auto;
            animation: rotate 2s linear infinite;
        }
        
        .center {
            position: absolute;
            top: 140px;
            left: 140px;
            width: 20px;
            height: 20px;
            background-color: rgb(87, 87, 87);
        }
        
        .box .hezi {
            display: flex;
            width: 150px;
            height: 150px;
            overflow: hidden;
        }
        
        .box .hezi:nth-child(1) span {
            width: 150px;
            height: 150px;
            margin-top: 75px;
            border-radius: 50% 50% 0 0;
            background: -webkit-linear-gradient( left top, rgb(90, 211, 90), #fff);
        }
        
        .box .hezi:nth-child(2) span {
            width: 150px;
            height: 150px;
            margin-left: -75px;
            border-radius: 0 50% 50% 0;
            background: -webkit-linear-gradient( left top, rgb(233, 79, 194), #fff);
        }
        
        .box .hezi:nth-child(3) span {
            width: 150px;
            height: 150px;
            margin-left: -75px;
            border-radius: 0 50% 50% 0;
            background: -webkit-linear-gradient( left top, rgb(93, 210, 240), #fff);
        }
        
        .box .hezi:nth-child(3) {
            transform: rotate(180deg);
        }
        
        .box .hezi:nth-child(4) span {
            width: 150px;
            height: 150px;
            margin-top: -75px;
            border-radius: 0 0 50% 50%;
            background: -webkit-linear-gradient( right top, rgb(252, 201, 91), #fff);
        }
        
        @keyframes rotate {
            0% {}
            100% {
                transform: rotate(360deg);
            }
        }

HTML代码如下(示例):

 <div class="box">
        <div class="hezi">
            <span></span>
        </div>
        <div class="hezi">
            <span></span>
        </div>
        <div class="hezi">
            <span></span>
        </div>
        <div class="hezi">
            <span></span>
        </div>
        <div class="center"></div>
    </div>

效果如下(示例):
在这里插入图片描述


博主会不定期更新一些有趣好玩的小案例来和大家分享学以致用的快乐。喜欢的朋友建议收藏学习。
在这里插入图片描述

  • 12
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

super码力

么么哒,夏天来块儿冰西瓜!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值