前言
兴趣是最好的老师。让我们一起在玩闹中学习吧,上次做了一个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>
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/6299.html