css3實現的動態月食效果代碼執行個體,css3動態月食執行個體

來源:互聯網
上載者:User

css3實現的動態月食效果代碼執行個體,css3動態月食執行個體

css3實現的動態月食效果代碼執行個體:
本章節分享一段代碼執行個體,它利用CSS3實現了動態月食效果。
動畫其實比較簡單簡短,需要的朋友可以自行做一下分析,這裡就不多介紹了。
代碼執行個體如下:

<!DOCTYPE html><html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css">*{  margin:0;  padding:0;}body{  background-color: #000;}.moonback{  width:600px;  height:600px;  background-color:#000;  margin:0 auto;  position: relative;}.moonback::before{  content:",";  display:block;  position:absolute;  left:200px;  top:100px;   width:200px;  height:200px;  background-color:#ff0;  border-radius:100px;}.moonback::after{  content:" ";  display:block;  position:absolute;  left:26px;  top:0px;   width:200px;  height:200px;  background-color:#000;  border-radius:100px;   -webkit-animation:12s dog linear infinite;  -moz-animation:12s dog linear infinite;  animation:12s dog linear infinite;   -webkit-animation-fill-mode:forwards;  -moz-animation-fill-mode: forwards;  animation-fill-mode: forwards;} @-webkit-keyframes dog{  0%{     left:27px;    top:0px;  }  100%{     left:399px;    top:216px;  }}@-moz-keyframes dog {  0%{     left:27px;    top:0px;  }  100%{     left:399px;    top:216px;  }}@keyframes dog{  0%{     left:27px;    top:0px;  }  100%{     left:399px;    top:216px;  }}.star{  position:absolute;}.star::before{  content:"★";  display:block;  position:absolute;  left:10px;  top:20px;   width:auto;  height:auto;  color:#fff;  -webkit-transform:scale(0.5);  -moz-transform:scale(0.5);  transform:scale(0.5);   -webkit-animation:1s starlight linear infinite;  -moz-animation:1s starlight linear infinite;  animation:1s starlight linear infinite;   -webkit-animation-fill-mode:forwards;  -moz-animation-fill-mode: forwards;  animation-fill-mode: forwards;}.star::after{  content:"★";  display:block;  position:absolute;  left:40px;  top:120px;    width:auto;   height:auto;   color:#fff;   -webkit-transform:scale(0.5);   -moz-transform:scale(0.5);   transform:scale(0.5);    -webkit-animation:2s starlight linear infinite;   -moz-animation: 2s starlight linear infinite;   animation: 2s starlight linear infinite;} @-webkit-keyframes starlight{  0%{     -webkit-transform:scale(0.5);  }  100%{     -webkit-transform:scale(0.1);  }}@-moz-keyframes starlight{  0%{     -moz-transform:scale(0.5);  }  100%{     -moz-transform:scale(0.1);  }}@keyframes starlight{  0%{     transform:scale(0.5);  }  100%{     transform:scale(0.1);  }} </style>  </head> <body>  <div class="content">    <div class="moonback">      <div class="star" style="top:20px;right:220px;"></div>      <div class="star" style="top:50px;right:120px;"></div>      <div class="star" style="top:190px;left:20px;"></div>      <div class="star" style="top:220px;left:50px;"></div>    </div>  </div> </body></html>

上面的代碼實現了我們的要求,更多內容可以參閱相關閱讀。
相關閱讀:
(1).::before可以參閱CSS的偽對象選擇符before/E::before一章節。
(2).border-radius可以參閱CSS3實現圓角效果一章節。
(3).animation可以參閱CSS3的animation屬性用法詳解一章節。
(4).animation-fill-mode可以參閱animation-fill-mode一章節。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=18153

更多內容可以參閱:http://www.softwhy.com/divcss/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.