300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > CSS3——旋转小风车

CSS3——旋转小风车

时间:2024-03-28 23:40:45

相关推荐

CSS3——旋转小风车

文章目录

前言一、知识点二、制作步骤三、详细代码

前言

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


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

一、知识点

背景线性渐变:

语法:

background:linear-gradient(起始方向,颜色1,颜色2,…);

background:-webkit-linear-gradient(left,red,blue);(兼容性)

background:-webkit-linear-gradient(left top,red,blue);(方向)

二、制作步骤

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

三、详细代码

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>

效果如下(示例):


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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。