|
很久以前的作品,于是就使用css3做了个于是就做了个充满童年回忆的大风车的大风车,感兴趣的朋友可以了解下啊,或许对你学习css3动画有所帮助,好了,话不多说,看代码
发一个很久以前的作品,当开始得知CSS3可以做动画时,就很想玩玩,于是就做了个充满童年回忆的大风车。
提示:您可以先修改部分代码再运行 HTML:
复制代码代码如下: <div class="windmill"> <div class="red"></div> <div class="yellow"></div> <div class="blue"></div> <div class="green"></div> <div class="dot"></div> </div>
实现过程:首先来一个容器里面四个风扇、 一个中心点 结构很简单,使用绝对分别定好位。然后再使用border-radius把风扇矩形变成半圆,形状就有了,再分别给其上色,红黄蓝绿四种渐变颜色。最后给容器加个animation使整个容器开始旋转即可。 CSS:
复制代码代码如下: .windmill{ padding:10px; width:400px; height:400px; position:relative; animation-name:moveWindmill; animation-duration:4s; animation-timing-function:linearanimation-delay:0; animation-iteration-count:infinite; animation-play-state:running; /* 动画: */ -moz-animation-name:moveWindmill; -moz-animation-duration:4s; -moz-animation-timing-function:linear; -moz-animation-delay:0; -moz-animation-iteration-count:infinite; -moz-animation-play-state:running; -webkit-animation-name:moveWindmill; -webkit-animation-duration:4s; -webkit-animation-timing-function:linear; -webkit-animation-delay:0; -webkit-animation-iteration-count:infinite; -webkit-animation-play-state:running; -ms-animation-name:moveWindmill; -ms-animation-duration:4s; -ms-animation-timing-function:linear; -ms-animation-delay:0; -ms-animation-iteration-count:infinite; -ms-animation-play-state:running; } .windmill div{ position:absolute; width:100px; height:50px;left:50%; top:50%; border-radius:0 0 50px 50px ; -moz-transform-origin:0% 0%;-webkit-transform-origin:0% 0%;-ms-transform-origin:0% 0%;} .windmill .red{ background-color:red; background: -moz-radial-gradient(right, circle,red , #000); background: -webkit-radial-gradient(right, circle,red , #000); } .windmill .yellow{transform:rotate(90deg); -ms-transform:rotate(90deg); -moz-transform:rotate(90deg); -webkit-transform:rotate(90deg); background-color:yellow; background: -moz-radial-gradient(right, circle,yellow , #000); background: -webkit-radial-gradient(right, circle,yellow , #000); background: -ms-radial-gradient(right, circle,yellow , #000);} .windmill .blue{transform:rotate(180deg);-ms-transform:rotate(180deg); -moz-transform:rotate(180deg); -webkit-transform:rotate(180deg); background-color:blue; background: -moz-radial-gradient(right, circle,blue , #000); background: -webkit-radial-gradient(right, circle,blue , #000); } .windmill .green{transform:rotate(270deg); -ms-transform:rotate(270deg);-moz-transform:rotate(270deg);-webkit-transform:rotate(270deg); background-color:green; background:radial-gradient(right, circle,green , #000);background: -moz-radial-gradient(right, circle,green , #000); background: -webkit-radial-gradient(right, circle,green , #000); background: -ms-radial-gradient(right, circle,green , #000); }.windmill .dot{ width:50px; height:50px; border-radius:50px ; position:absolute; left:50%;top:50%; margin-left:-25px; margin-top:-25px;background:#fff; background: -moz-radial-gradient(center, circle,#fff , #666); background: -webkit-radial-gradient(center, circle,#fff , #666);} @keyframes moveWindmill /* Firefox */ { % { -ms-transform: rotate(0deg)} % { -ms-transform: rotate(90deg)} % { -ms-transform: rotate(180deg)} % { -ms-transform: rotate(270deg)} % { -ms-transform: rotate(360deg)} } @-ms-keyframes moveWindmill /* ms*/ { % { -ms-transform: rotate(0deg)} % { -ms-transform: rotate(90deg)} % { -ms-transform: rotate(180deg)} % { -ms-transform: rotate(270deg)} % { -ms-transform: rotate(360deg)} } @-webkit-keyframes moveWindmill /*webkit*/ { % { -webkit-transform: rotate(0deg)} % { -webkit-transform: rotate(90deg)} % { -webkit-transform: rotate(180deg)} % { -webkit-transform: rotate(270deg)} % { -webkit-transform: rotate(360deg)} } @-moz-keyframes moveWindmill /* Firefox */ { % { -moz-transform: rotate(0deg)} % { -moz-transform: rotate(90deg)} % { -moz-transform: rotate(180deg)} % { -moz-transform: rotate(270deg)} % { -moz-transform: rotate(360deg)} }
|
|