css3实现的动态月食效果代码实例_html/css_WEB-ITnose
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/

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

熱門話題

本文討論了HTML&lt; Progress&gt;元素,其目的,樣式和與&lt; meter&gt;元素。主要重點是使用&lt; progress&gt;為了完成任務和LT;儀表&gt;對於stati

本文討論了html&lt; datalist&gt;元素,通過提供自動完整建議,改善用戶體驗並減少錯誤來增強表格。Character計數:159

本文討論了使用HTML5表單驗證屬性,例如必需的,圖案,最小,最大和長度限制,以直接在瀏覽器中驗證用戶輸入。

本文討論了HTML&lt; meter&gt;元素,用於在一個範圍內顯示標量或分數值及其在Web開發中的常見應用。它區分了&lt; meter&gt;從&lt; progress&gt;和前

本文討論了視口元標籤,這對於移動設備上的響應式Web設計至關重要。它解釋瞭如何正確使用確保最佳的內容縮放和用戶交互,而濫用可能會導致設計和可訪問性問題。

本文討論了&lt; iframe&gt;將外部內容嵌入網頁,其常見用途,安全風險以及諸如對象標籤和API等替代方案的目的。

HTML適合初學者學習,因為它簡單易學且能快速看到成果。 1)HTML的學習曲線平緩,易於上手。 2)只需掌握基本標籤即可開始創建網頁。 3)靈活性高,可與CSS和JavaScript結合使用。 4)豐富的學習資源和現代工具支持學習過程。
