CSS3月食

來源:互聯網
上載者:User

昨天據說是XXX什麼的月食,於是學習CSS3的時候也實現一個,全當練手。

實現原理很簡單,用一個大圓覆蓋一個小圓···=。=·:

用基於webkit的瀏覽器測試,需要其他的瀏覽器可以更改對應的首碼(-webkit,-moz,-o)

示範地址:http://fronter.sinaapp.com/wp-content/demo/eclipse.html

 

最終效果:

 

demo:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
body{ background: #000;}
#earth{position: relative; margin-top: 200px; }
#moon{
position: absolute; top:-90px; left: 50%; width: 180px; height: 180px; margin-left: -90px;
border-radius: 100px;
background: -webkit-gradient(linear, left bottom, right top, from(#BDA08D), to(#fff));
box-shadow: 0 0 30px #D4D4D4;
}
#lovers{
position: absolute;
top:73px;
border-radius: 0 0 0 90px;
-webkit-transform:rotate(-1deg);
}
#dog{
position: absolute; top:850px; left: 400px; width: 300px; height: 300px; border-radius: 150px; background: #000;
}
#orbit{
position: relative; top:-1000px; width: 1000px; height: 1000px; margin: 0 auto; border-radius: 500px;
-webkit-animation-name:eclipse;
-webkit-animation-duration:20s;
-webkit-animation-timing-function:linear;
-webkit-animation-iteration-count:infinite;
}
@-webkit-keyframes eclipse{
0%{-webkit-transform: rotate(-30deg);}
20%{-webkit-transform: rotate(-15deg);}
40%{-webkit-transform: rotate(0deg);}
60%{-webkit-transform: rotate(15deg);}
80%{-webkit-transform: rotate(30deg);}
100%{-webkit-transform: rotate(45deg);}
}
</style>
</head>
<body>
<div id="earth">
<div id="moon">
<img id="lovers" src="http://images.cnblogs.com/cnblogs_com/xesam/341774/r_%E6%9C%AA%E6%A0%87%E9%A2%98-2.png" width="100" alt="" />
</div>
<div id="orbit">
<div id="dog"></div>
</div>
</div>
<script type="text/javascript">
var dog = document.getElementById('dog');

</script>
</body>
</html>

 

轉載請註明來自小西山子【http://www.cnblogs.com/xesam/】
本文地址:http://www.cnblogs.com/xesam/archive/2011/12/11/2283712.html

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.