本篇內容主要講解“怎么用CSS3繪制一個月食圖案”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“怎么用CSS3繪制一個月食圖案”吧!
10年積累的網站設計制作、做網站經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先網站制作后付款的網站建設流程,更有金平免費網站建設讓你可以放心的選擇與我們合作。
畫個月亮嘛,還是嘗試用一個div來實現,主div做背景黑夜,before做月亮,after做擋住月亮的黑影。
用position控制位置,用animation控制動畫。
CSS Code復制內容到剪貼板
.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: 8s dog linear infinite;
-moz-animation: 8s dog linear infinite;
animation: 8s dog linear infinite;
}
@-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;
}
}
最好body也設成背景黑,那就更好了~
等等,看不到星星的天空,缺少了幸福感。
正好偷師一下,一個div里的美隊盾做法,直接用★
也給個動畫效果,放大縮小~
CSS Code復制內容到剪貼板
.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;
}
.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);
}
}
效果圖如下:
效果頁面>>
完畢,嗯,再給月亮加個顏色漸變?
到此,相信大家對“怎么用CSS3繪制一個月食圖案”有了更深的了解,不妨來實際操作一番吧!這里是創新互聯網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
網站標題:怎么用CSS3繪制一個月食圖案
URL地址:http://vcdvsql.cn/article22/jhiocc.html
成都網站建設公司_創新互聯,為您提供網站建設、做網站、用戶體驗、企業建站、商城網站、網站策劃
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯