ホームページ  >  記事  >  ウェブフロントエンド  >  css3_html/css_WEB-ITnose で実装された動的月食エフェクト コードの例

css3_html/css_WEB-ITnose で実装された動的月食エフェクト コードの例

WBOY
WBOYオリジナル
2016-06-24 11:27:121350ブラウズ

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) 境界線の半径については、角丸効果を実現するための 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/

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。