首页 > 作文

CSS3 制作旋转的大风车(充满童年回忆)

更新时间:2023-04-03 15:51:10 阅读: 评论:0

发一个很久以前的作品,当开始得知css3可以做动画时,就很想玩玩,于是就做了个充满童年回忆的大风车。

<!doctype html public “-//w3c//dtd xhtml 1.0 transitional//en” “/d/file/titlepic/xhtml1-transitional.dtd& <html xmlns=”http://www.w3.org/1999/xhtml”> <head> <meta http-equiv=”content-type” content=”text/html; chart=gb2312″ /> <title>css3 大风车</title> <style> *{margin:0; padding:0} .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; /* firefox: */ -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 */ { 0% { -ms-transform: rotate(0deg)} 25% { -ms-transform: rotate(90deg)} 50% { -ms-transform: rotate(180deg)} 75% { -ms-transform: rotate(270deg)} 100% { -ms-transform: rotate(360deg)} } @-ms-keyframes movewindmill /* firefox */ { 0% { -ms-transform: rotate(0deg)} 25% { -ms-transform: rotate(90deg)} 50% { -ms-transform: rotate(180deg)} 75% { -ms-transform: rotate(270deg)} 100% { -ms-transform: rotate(360deg)} } @-webkit-keyframes movewindmill /* firefox */ { 0% { -webkit-transform: rotate(0deg)} 25% { -webkit-transform: rotate(90deg)} 50% { -webkit-transform: rotate(180deg)} 75% { -webkit-transform: rotate(270deg)} 100% { -webkit-transform: rotate(360deg)} } @-moz-keyframes movewindmill /* firefox */ { 0% { -moz-transform: rotate(0deg)} 25% { -moz-transform: rotate(90deg)} 50% { -moz-transform: rotate(180deg)} 75% { -moz-transform: rotate(270deg)} 100% { -moz-transform: rotate(360deg)} } </style> </head> <body> <div class=”windmill”> <div class=”red”></div> <div class=”yellow”></div> <div class=”blue”></div> <div class=”green”></div> <div class=”dot”></div> </div> </body> </html>

提示:您可以先修改部分代码再运行

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; b独一无二的沙雕网名ackground: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)}

%2021建党100周年图片 { -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-t文艺复兴后三杰ransform: rotate(0deg)}

% { -moz-transform: rotate(90deg)}

% { -moz-transform: rotate(180deg)}

% { -moz-transform: rotate(270deg)}

% { -moz-transform: rotate(360deg)}

}


本文发布于:2023-04-03 15:51:05,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/c8321db6321f6e7f4f9f11de4bf0f3c6.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:CSS3 制作旋转的大风车(充满童年回忆).doc

本文 PDF 下载地址:CSS3 制作旋转的大风车(充满童年回忆).pdf

标签:代码   容器   风扇   动画
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图