纯css实现日全食的原理解释动画效果
代码语言:html
所属分类:动画
代码描述:纯css实现日全食的原理解释动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
background: #21223a;
}
.container {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.sun {
width: 150px;
height: 150px;
background: #fffaa9;
border-radius: 100%;
box-shadow: 0 0 60px #ffcfa9, 0 0 100px #b9a018;
position: relative;
left: 250px;
}
.sun .left-eye, .sun .left-eye::after {
position: relative;
border-top-right-radius: 90px;
border-top-left-radius: 90px;
background: #ffcfa9;
width: 25px;
height: 12.5px;
transform: scale(1.5);
top: 60px;
left: 30px;
animation: sun-lefteye 2.3s ease-in-out infinite;
}
.sun .left-eye::after {
content: "";
position: absolute;
background: #fffaa9;
left: 0px;
top: 3px;
transform: scale(0.9);
animation: sun-eye-smol 2.3s ease-in-out infinite;
}
.sun .right-eye, .sun .right-eye::after {
position: absolute;
border-top-right-radius: 90px;
border-top-left-radius: 90px;
background: #ffcfa9;
width: 25px;
height: 12.5px;
transform: scale(1.5);
top: 60px;
left: 90px;
animation: sun-righteye 2.3s ease-in-out infinite;
}
.sun .right-eye::after {
content: "";
position: absolute;
background: #fffaa9;
left: 0px;
top: 3px;
transform: scale(0.9);
animation: sun-eye-smol 2.3s ease-in-out infinite;
}
.left-eyelash, .left-eyelash::after, .right-eyelash::after,
.right-eyelash {
position: relative;
width: 2.5px;
height: 8px;
background: #ffcfa9;
border-radius: 200px;
}
.left-eyelash, .left-eyelash::after, .right-eyelash::after {
top: 2px;
transform: rotate(-45deg);
}
.left-eyelash::after, .right-eyelash::after {
content: "";
position: absolute;
top: -1px;
left: 3px;
transform: rotate(5deg);
}
.right-eyelash {
top: -1px;
left: 21px;
transform: rotate(45deg);
}
.right-eyelash::after {
content: "";
position: absolute;
top: 1px;
left: 3px;
}
.rays {
position: absolute;
transform-origin: center;
margin: auto;
width: 150px;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
animation: spin 120s linear infinite;
}
.beam {
background: linear-gradient(0deg, rgba(255, 255, 255, 0), #ffcfa9 40%, #ffcfa9);
margin-left: 10px;
border-radius: 50% 50% 0 0;
position: absolute;
opacity: 0.03;
height: 110px;
}
.beam:nth-child(1) {
width: 40px;
transform: rotate(180deg);
top: -90px;
left: 42px;
}
.beam:nth-child(2) {
width: 30px;
transform: rotate(210deg);
right: -5px;
top: -80px;
}
.beam:nth-child(3) {
width: 50px;
transform: rotate(255deg);
top: -20px;
right: -65px;
}
.beam:nth-child(4) {
width: 24px;
transform: rotate(300deg);
top: 60px;
left: 150px;
}
.beam:nth-child(5) {
width: 40px;
top: 135px;
left: 40px;
}
.beam:nth-child(6) {
width: 30px;
transform: rotate(-35deg);
top: 115px;
right: -12px;
}
.beam:nth-child(7) {
width: 45px;
transform: rotate(45deg);
top: 100px;
left: -45px;
}
.beam:nth-child(8) {
width: 20px;
transform: rotate(75deg);
top: 40px;
left: -70px;
}
.beam:nth-child(9) {
width: 50px;
transform: rotate(-250deg);
top: -30px;
left: -70px;
}
.beam:nth-child(10) {
width: 20px;
transform: rotate(145deg);
top: -80px;
left: -15px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes sun-lefteye {
50% {
left: 40px;
}
}
@keyframes sun-eye-smol {
50% {
left: 0px;
}
}
@keyframes sun-righteye {
50% {
left: 100px;
}
}
.moon {
width: 80px;
height: 80px;
background: #e3e7ea;
border-radius: 100%;
position: absolute;
top: 110px;
right: 130px;
transform-origin: 200px center;
overflow: hidden;
transform: rotate(-20deg);
animation: moonOrbit 5s infinite 0.3s;
}
.moon::after {
content: "";
width: 80px;
height: 80px;
background: transparent;
border-radius: 100%;
position: absolute;
box-shadow: inset 15px -3px 0px #637684;
z-index: 3;
opacity: 0.2;
}
.moon .craters {
position: absolute;
animation: moonScroll 5s linear infinite 0.3s;
}
.moon .craters:nth-child(1) {
width: 40px;
height: 40px;
background: #ccd3d9;
border-radius: 100%;
}
.moon .craters:nth-child(2) {
width: 10px;
height: 10px;
background: #ccd3d9;
border-radius: 100%;
left: 40px;
top: 35px;
}
.moon .craters:nth-child(3) {
width: 40px;
height: 40px;
background: #ccd3d9;
border-radius: 100%;
left: 60px;
}
.moon .craters:nth-child(4) {
width: 20px;
height: 20px;
background: #ccd3d9;
border-radius: 100%;
top: 45px;
}
.moon .craters:nth-child(5) {
width: 30px;
height: 30px;
background: #ccd3d9;
border-radius: 100%;
top: 55px;
left: 30px;
}
.moon .eyes {
display: flex;
justify-content: space-between;
position: absolute;
top: 35px;
transform: translateX(-50);
}
.moon .eyes::before, .moon .eyes::after {
display: block;
content: "";
position: relative;
width: 20px;
height: 5px;
right: 25%;
border-radius: 200px;
background: #637684;
margin: 0 3px;
animation: blink 3.5s infinite;
}
.moon .eyes::before {
transform: rotate(30deg);
}
.moon .eyes::after {
transform: rotate(-30deg);
}
@keyframes moonOrbit {
20%,
25% {
transform: rotate(50deg);
}
55%,
60% {
transform: rotate(-20deg);
}
}
@keyframes blink {
0% {
top: 0px;
height: 5px;
}
18% {
top: 0px;
height: 5px;
}
20% {
top: 3px;
height: 2px;
}
25% {
top: 0px;
height: 5px;
}
38% {
top: 0px;
height: 5px;
}
40% {
top: 3px;
height: 2px;
}
45% {
top: 0px;
height: 5px;
}
80% {
top: 0px;
height: 5px;
}
100% {
top: 0px;
height: 5px;
}
}
.earth {
position: absolute;
display: block;
right: 300px;
top: 100px;
width: 120px;
height: 120px;
background: #6fd4dd;
border-radius: 100%;
transform: rotate(-20deg);
transform-origin: 400px center;
overflow: hidden;
animation: earthOrbit 5s infinite;
}
.earth::after {
content: "";
width: 120px;
height: 120px;
background: transparent;
border-radius: 100%;
position: absolute;
box-shadow: inset 10px 1px 0px #1d747c;
z-index: 3;
opacity: 0.2;
}
@keyframes earthOrbit {
20%,
25% {
transform: rotate(50deg);
}
55%,
60% {
transform: rotate(-20deg);
}
}
.countries {
position: absolute;
z-index: 1;
animation: scroll 5s linear alternate infinite;
}
.countries:nth-child(1) {
width: 40px;
height: 40px;
background: #62e5aa;
border-radius: 100%;
left: 5px;
top: 20px;
}
.countries:nth-child(2) {
width: 50px;
height: 50px;
background: #62e5aa;
border-radius: 100%;
left: 25px;
top: 45px;
}
.countries:nth-child(3) {
width: 35px;
height: 35px;
background: #62e5aa;
border-radius: 100%;
left: 60px;
top: 20px;
}
.countries:nth-child(4) {
width: 55px;
height: 55px;
background: #62e5aa;
border-radius: 100%;
left: 90px;
top: 50px;
}
.countries:nth-child(5) {
width: 60px;
height: 60px;
background: #62e5aa;
border-radius: 100%;
left: 75px;
}
.countries:nth-child(6) {
width: 50px;
height: 50px;
background: #62e5aa;
border-radius: 100%;
top: 110px;
left: 35px;
}
.countries:nth-child(7) {
width: 30px;
height: 30px;
background: #62e5aa;
border-radius: 100%;
top: 20px;
left: -50px;
}
.eyes {
display: flex;
justify-content: space-between;
position: absolute;
z-index: 3;
top: 15px;
left: 25%;
}
.eyes .opened::before,
.eyes .opened::after {
display: block;
content: "\2665";
color: #f55020;
font-size: 40px;
margin: 0 8px;
animation: openBlink 5s linear infinite;
}
.eyes .closed::before,
.eyes .closed::after {
display: block;
content: "";
background: transparent;
width: 30px;
height: 30px;
border-radius: 50%;
box-shadow: 5px 5px 0 0 #1d747c;
margin: 8px 8px;
transform: rotate(45deg);
opacity: 0;
animation: closedEyes 5s linear infinite;
}
.tear {
position: absolute;
width: 8px;
height: 8px;
border-radius: 0 50% 50% 50%;
background: #54acb7;
top: 65px;
z-index: 3;
left: 35px;
opacity: 0;
transform: rotate(60deg);
animation: crying 5s infinite 3s;
}
@keyframes crying {
from {
opacity: 1;
transform: translateY(0px) rotate(60deg);
}
to {
opacity: 0;
transform: translateY(50px);
}
}
@keyframes openBlink {
0% {
transform: scaleY(1);
}
18% {
transform: scaleY(1);
}
20% {
transform: scaleY(0);
}
25% {
transform: scaleY(1);
}
38% {
transform: scaleY(1);
}
40% {
transform: scaleY(0);
}
45% {
transform: scaleY(1);
}
48% {
transform: scaleY(0), scaleX(0);
opacity: 1;
}
50% {
margin-top: 8px;
opacity: 0;
}
72% {
opacity: 0;
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
@keyframes closedEyes {
45% {
opacity: 0;
margin-top: 8px;
}
49% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 1;
margin-top: 15px;
}
}
.shadow {
width: 100px;
height: 100px;
background: #21223a;
border-radius: 100%;
z-index: 2;
position: absolute;
opacity: 0.2;
right: 270px;
top: 210px;
transform-origin: 650px center;
animation: shadowOrbit 5s infinite 0.3s;
}
@keyframes shadowOrbit {
20%,
25% {
transform: rotate(35deg);
}
55%,
60% {
transform: rotate(0deg);
}
}
@keyframes scroll {
50% {
transform: translateX(-90px);
}
}
@keyframes moonScroll {
50% {
transform: translateX(-40px);
}
}
.excited {
position: absolute;
font-weight: bold;
font-family: Arial;
z-index: -1;
color: white;
top: 200px;
right: 400px;
font-size: 0px;
transform: rotate(-30deg);
animation: excited 5s infinite 4.5s;
}
@keyframes excited {
0% {
font-size: 0px;
}
2% {
font-size: 25px;
}
10% {
opacity: 1;
font-size: 25px;
}
20% {
opacity: 0;
font-size: 25px;
}
100% {
opacity: 0;
font-size: 0px;
}
}
@keyframes star-animation {
0% {
transform: rotate(-20deg) translateX(-1000px);
}
100% {
transform: rotate(-20deg) translateX(1000px);
}
}
.stars1 {
z-index: -1;
width: 1px;
height: 1px;
border-radius: 50%;
box-shadow: 143vh 394vh #FFF , 483vh 512vh #FFF , 70vh 346vh #FFF , 10vh 460vh #FFF , 679vh 478vh #FFF , 528vh 184vh #FFF , 432vh 634vh #FFF , 560vh 343vh #FFF , 631vh 260vh #FFF , 797vh 323vh #FFF , 360vh 513vh #FFF , 849vh 690vh #FFF , 655vh 427vh #FFF , 476vh 775vh #FFF , 113vh 737vh #FFF , 792vh 355vh #FFF , 581vh 346vh #FFF , 857vh 648vh #FFF , 412vh 888vh #FFF , 411vh 592vh #FFF , 481vh 778vh #FFF , 18vh 773vh #FFF , 13vh 103vh #FFF , 575vh 632vh #FFF , 429vh 89vh #FFF , 737vh 363vh #FFF , 190vh 65vh #FFF , 497vh 421vh #FFF , 625vh 539vh #FFF , 462vh 115vh #FFF , 126vh 441vh #FFF , 939vh 736vh #FFF , 12vh 127vh #FFF , 969vh 42vh #FFF , 361vh 465vh #FFF , 240vh 660vh #FFF , 263vh 613vh #FFF , 378vh 506vh #FFF , 844vh 813vh #FFF , 602vh 696vh #FFF , 801vh 563vh #FFF , 18vh 721vh #FFF , 18vh 152vh #FFF , 241vh 495vh #FFF , 484vh 777vh #FFF , 801vh 516vh #FFF , 168vh 589vh #FFF , 402vh 792vh #FFF , 440vh 668vh #FFF , 703vh 695vh #FFF , 321vh 565vh #FFF , 840vh 314vh #FFF , 750vh 69vh #FFF , 639vh 858vh #FFF , 692vh 541vh #FFF , 378vh 229vh #FFF , 975vh 213vh #FFF , 976vh 392vh #FFF , 137vh 644vh #FFF , 927vh 758vh #FFF , 138vh 845vh #FFF , 751vh 47vh #FFF , 998vh 483vh #FFF , 311vh 662vh #FFF , 251vh 397vh #FFF , 509vh 22vh #FFF , 202vh 143vh #FFF , 483vh 475vh #FFF , 748vh 861vh #FFF , 149vh 551vh #FFF , 339vh 259vh #FFF , 358vh 401vh #FFF , 394vh 693vh #FFF , 767vh 745vh #FFF , 781vh 135vh #FFF , 904vh 211vh #FFF , 933vh 243vh #FFF , 101vh 382vh #FFF , 532vh 732vh #FFF , 155vh 238vh #FFF , 397vh 690vh #FFF , 795vh 541vh #FFF , 174vh 758vh #FFF , 546vh 58vh #FFF , 214vh 88vh #FFF , 106vh 319vh #FFF , 344vh 624vh #FFF , 418vh 372vh #FFF , 150vh 787vh #FFF , 508vh 721vh #FFF , 694vh 737vh #FFF , 960vh 179vh #FFF , 360vh 678vh #FFF , 968vh 334vh #FFF , 340vh 629vh #FFF , 294vh 222vh #FFF , 49vh 661vh #FFF , 660vh 464vh #FFF , 218vh 848vh #FFF , 101vh 583vh #FFF , 763vh 587vh #FFF , 590vh 451vh #FFF , 228vh 722vh #FFF , 343vh 577vh #FFF , 859vh 158vh #FFF , 901vh 799vh #FFF , 679vh 47vh #FFF , .........完整代码请登录后点击上方下载按钮下载查看
网友评论0