CSS实现动态风车转动

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>风车梳理</title>
	<style>
      #wrap{
      	/*border:solid 1px #ccc;*/
      	height:600px;width:1100px;
      	margin:0 auto;
      	margin-top:95px;
      	position:relative;/*便于子元素位移*/
      }
      #zhuzi{
      	/*柱子为梯形,回想边框模型可以知道设计原理*/
      	position:absolute;
      	left:535px;bottom:0px;
      	width:12px;height:0px;
      	border-width:0px 25px 380px 25px;
      	border-style:none solid solid;
      	border-color:transparent transparent #996669 transparent;
      }
      #zhou{
      	width:50px;height:50px;
      	background:red;
      	position:absolute;  /*子元素的绝对定位会覆盖父元素*/
      	left:541px;top:196px;
      	/*定义动画周期*/
      	animation:fengchezhuandong 3s;
      	/*设定转动次数为无限*/
        animation-iteration-count:infinite;
        /*定义转动速率为匀速*/
        animation-timing-function:linear;}
        /*定义动画*/
      @keyframes fengchezhuandong{
      	from{transform:rotate(0deg);}
      	to{transform:rotate(360deg);}
      }
			/*定义风车叶子基础模型*/
      .zhizhen{
      	width:12px;height:4px;
      	position:absolute;
      	left:25px;top:25px;
      	border-width:0px 0px 125px 280px;
      	border-style:none none solid solid ;
      	border-color:transparent transparent transparent blue ;
      	transform-origin:0 0;
      }
			/*分别定义风车叶子的初始位置和不同颜色以区分*/
			/*z1不必定义即为基础模型即可,其他的叶子只需在基础模型的基础上旋转一定角度设置不同颜色即可*/
      .z2{
      	transform:rotate(90deg);
        border-color:transparent transparent transparent red; }
      .z3{
      	transform:rotate(180deg);
        border-color:transparent transparent transparent purple; }
      .z4{
      	transform:rotate(270deg);
        border-color:transparent transparent transparent yellow;
      }
			/*不同的风车叶子旋转时的中心设置为转轴,此轴与上面上面的轴是覆盖关系*/
      .zhuanzhou{
      	width:50px;height:50px;background:green;
      	position:absolute;
      	border-radius:25px;
      }
	</style>
</head>
<body>
   <div id="wrap">
   	 <div id="zhuzi"></div>
   	 <div id="zhou">
   	 	<div class="zhizhen z1"></div>
   	 	<div class="zhizhen z2"></div>
   	 	<div class="zhizhen z3"></div>
   	 	<div class="zhizhen z4"></div>
   	 	<div class="zhuanzhou"></div>
   	 </div>
   </div>
</body>
</html>
  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值