纯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: ""; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0