HTML+CSS大风车及十字架的实现
2015-08-31 18:10
609 查看
说起大风车勾起了多少人的回忆,
我们今天就利用CSS做一个大风车并且让它转起来。
首先还是老规矩——先上效果图:
![](http://img.blog.csdn.net/20150831181323217?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](http://img.blog.csdn.net/20150831181338518?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
一................ 不是说好了转起来的吗?怎么在那不动啊。哈哈哈。。。。
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/titter.gif)
老毛病又犯了是不,不要着急嘛。
由于不会搞视频,只能等你们自己做出来,你们再去看效果吧,真的很炫酷的哦!
HTML代码:
代码很少同样也很简单,就是五个div进行的定位组成的大风车
来看看是怎么定位的吧:
同学会问怎么让它动起来的呢?
嘿嘿嘿
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/shy.gif)
,就在上面那段你看不懂的代码,
搞回去细细琢磨一下吧。
第二种样式只有CSS和上面略微不同:
第三种:
好了这三种方法回去试一下吧,
有助于帮助你学习CSS中的定位
我们今天就利用CSS做一个大风车并且让它转起来。
首先还是老规矩——先上效果图:
一................ 不是说好了转起来的吗?怎么在那不动啊。哈哈哈。。。。
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/titter.gif)
老毛病又犯了是不,不要着急嘛。
由于不会搞视频,只能等你们自己做出来,你们再去看效果吧,真的很炫酷的哦!
HTML代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>第一种</title> <link rel="stylesheet" type="text/css" href="cross.css"> </head> <body> <div id="overall"> <div id="first"></div> <div id="second"></div> <div id="third"> <img src="3D.ico"> </div> <div id="fourth"></div> <div id="fifth"></div> </div> </body> </html>
代码很少同样也很简单,就是五个div进行的定位组成的大风车
来看看是怎么定位的吧:
div { width: 100px; height: 100px; /*float: left;*/ position: absolute; border-color: orange; border-radius: 20px; /*border-spacing: 5px;*/ } #overall { width: 300px; height: 300px; position: absolute; left: 50%; top: 50%; margin-top: -150px; margin-left: -150px; border: none; animation:myanim 3s infinite; -webkit-animation: myanim 3s infinite; } #first { background-color: #63A12C; left: 100px; } #second { background-color: #2C34A1; top: 100px; } #third { background-color: #3D82B7; top: 100px; left: 100px; } img { width: 24px; height: 24px; position: absolute; left: 50%; top: 50%; margin-top: -12px; margin-left: -12px; } #fourth { background-color: #A92D7F; top: 100px; left: 200px; } #fifth { background-color: #2ACBB6; top: 200px; left: 100px; } /* 旋转效果*/ @keyframes myanim { 0% { transform: rotate(0deg); } 100% { transform: rotate(-360deg); } } @-webkit-keyframes myanim { 0% { transform: rotate(0deg); } 100% { transform: rotate(-360deg); } }
同学会问怎么让它动起来的呢?
嘿嘿嘿
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/shy.gif)
,就在上面那段你看不懂的代码,
搞回去细细琢磨一下吧。
第二种样式只有CSS和上面略微不同:
div { width: 100px; height: 100px; /*border-radius: 50%;*/ } .overall { width: 300px; height: 300px; position: fixed; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); display: block; /* -webkit-transition:0.4s linear; -webkit-transition:0.4s ease-in;*/ -webkit-transition: all 1s ease-in-out; } #first { background-color: #63A12C; margin-left: 100px; } #second { background-color: #2C34A1; margin-right: 200px; } #third { background-color: #3D82B7; margin-left: 100px; margin-top: -100px; } img { width: 24px; height: 24px; /*µÚÒ»ÖÖ·½·¨*/ /* position: absolute; left: 50%; top: 50%; margin-top: -12px; margin-left: -12px;*/ margin-top: 38px; margin-left: 38px; } #fourth { background-color: #A92D7F; margin-left: 200px; margin-top: -100px; } #fifth { background-color: #2ACBB6; margin-left: 100px; } .overall:hover { -webkit-transform: rotate(180deg) scale(3.0) translate(100px, 0); }
第三种:
div { width: 100px; height: 100px; border-radius: 50%; } .overall { width: 300px; height: 300px; position: fixed; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); } #first { background-color: #3D82B7; margin-left: 100px; } #second { background-color: #2C34A1; margin-right: 200px; } #third { background-color: #9400D3; margin-left: 100px; margin-top: -100px; display: table; text-align: center; -webkit-transition: background-color 1s ease-in; } #third:hover { background-color: #32CD32; } .img { display: table-cell; vertical-align: middle; } #fourth { background-color: #A92D7F; margin-left: 200px; margin-top: -100px; } #fifth { background-color: #2ACBB6; margin-left: 100px; }
好了这三种方法回去试一下吧,
有助于帮助你学习CSS中的定位
相关文章推荐
- 详解CSS中的Box Model盒属性的使用
- css ie6,ie7,ie8 兼容性写法,CSS hack写法
- 经常使用的两个清爽的table样式
- 百度地图 v3.5搜索功能,和地图缩放按钮更改样式
- css3中创建动画的三种方式详解
- 你应该知道的CSS文字大小单位PX、EM、PT
- 如何使CSS--better(系列二)
- 如何使CSS--better(系列一)
- FontAwesome图标制作(css)
- 设置浏览器默认样式
- [CSS] Transforms
- CSS选择器与样式优先级
- JS获取CSS属性值
- CSS控制文本自动换行
- css3实现的多级渐变下拉菜单导航效果代码
- 表单元素的css样式,自适应屏幕
- CSS3实现可关闭的下拉手风琴菜单效果
- CSS选择器
- 利用css3中的after和content制作简单的tooltip
- [ElasticsSearch] 排序(一)