css模拟森林的各种天气和季节变换效果代码
代码语言:html
所属分类:动画
代码描述:css模拟森林的各种天气和季节变换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --bgd-color: #cbe9f4; --light: #93d5eb; --medium: #66bbd8; --dark: #4da2bb; --bush: #ffffff; --trunk: #c2653c; --trunk2: #9d5d5d; --cloud: #ffffff; --sun: transparent; --rabbit: #ffffff; } *, *:before, *:after { -webkit-transition: 4s ease background; transition: 4s ease background; position: absolute; } body { padding: 0; margin: 0; overflow: hidden; background-color: var(--bgd-color); display: -webkit-box; display: flex; -webkit-box-align: center; align-items: center; -webkit-box-pack: center; justify-content: center; height: 100vh; width: 100vw; } .container { position: relative; width: 800px; height: 450px; } .sun { background-color: var(--sun); width: 60px; height: 60px; border-radius: 100%; top: -20px; left: 180px; } .rainbow { visibility: hidden; width: 600px; height: 270px; left: 100px; bottom: 82px; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); } .rainbow.animated { -webkit-animation: rainbow 14s linear; animation: rainbow 14s linear; visibility: visible; } .rainbow .rainbow-colour { border-top-left-radius: 50% 100%; border-top-right-radius: 50% 100%; border-bottom: 0; left: 50%; -webkit-transform: translate(-50%, 0); transform: translate(-50%, 0); -webkit-transform-origin: 0 100%; transform-origin: 0 100%; bottom: 0; border-bottom: 0 !important; } .rainbow .rainbow-colour:nth-child(1) { border: 10px solid #ac01fd; height: 100%; width: 100%; } .rainbow .rainbow-colour:nth-child(2) { border: 10px solid #511ce0; height: 261px; width: 581px; } .rainbow .rainbow-colour:nth-child(3) { border: 10px solid #1a9fe2; height: 252px; width: 562px; } .rainbow .rainbow-colour:nth-child(4) { border: 10px solid #5ed81d; height: 243px; width: 543px; } .rainbow .rainbow-colour:nth-child(5) { border: 10px solid #f8f52a; height: 234px; width: 524px; } .rainbow .rainbow-colour:nth-child(6) { border: 10px solid #f7a528; height: 225px; width: 505px; } .rainbow .rainbow-colour:nth-child(7) { border: 10px solid #f63b2a; height: 216px; width: 486px; } @-webkit-keyframes rainbow { 0% { opacity: 0; } 10% { opacity: 0.5; } 80% { opacity: 0.5; } 100% { opacity: 0; } } @keyframes rainbow { 0% { opacity: 0; } 10% { opacity: 0.5; } 80% { opacity: 0.5; } 100% { opacity: 0; } } .cloud-group { width: 100%; height: 100%; top: 0; left: 0; overflow: hidden; } .cloud { background-color: var(--cloud); width: 80px; height: 30px; border-radius: 50px; left: 50px; top: 40px; -webkit-animation: clouds 10s linear infinite; animation: clouds 10s linear infinite; } @-webkit-keyframes clouds { 50% { -webkit-transform: translateX(20px); transform: translateX(20px); } 100% { -webkit-transform: translateX(0); transform: translateX(0); } } @keyframes clouds { 50% { -webkit-transform: translateX(20px); transform: translateX(20px); } 100% { -webkit-transform: translateX(0); transform: translateX(0); } } .weather-container { width: 100%; height: 400px; } .snow { opacity: 0; background-color: #ffffff; width: 6px; height: 6px; border-radius: 100%; -webkit-transition: 2s ease all; transition: 2s ease all; -webkit-animation: snow 5s linear infinite; animation: snow 5s linear infinite; } .snow:nth-of-type(1) { top: 11px; left: 34px; -webkit-animation-delay: 2s; animation-delay: 2s; } .snow:nth-of-type(2) { top: 20px; left: 65px; -webkit-animation-delay: 4s; animation-delay: 4s; } .snow:nth-of-type(3) { top: 18px; left: 18px; -webkit-animation-delay: 6s; animation-delay: 6s; } .snow:nth-of-type(4) { top: 8px; left: 70px; -webkit-animation-delay: 3s; animation-delay: 3s; } .snow:nth-of-type(5) { top: 4px; left: 19px; -webkit-animation-delay: 4s; animation-delay: 4s; } .snow:nth-of-type(6) { top: 25px; left: 26px; -webkit-animation-delay: 1s; animation-delay: 1s; } .snow:nth-of-type(7) { top: 24px; left: 66px; -webkit-animation-delay: 1s; animation-delay: 1s; } .snow:nth-of-type(8) { top: 3px; left: 29px; -webkit-animation-delay: 10s; animation-delay: 10s; } .snow:nth-of-type(9) { top: 21px; left: 5px; -webkit-animation-delay: 6s; animation-delay: 6s; } .snow:nth-of-type(10) { top: 26px; left: 19px; -webkit-animation-delay: 1s; animation-delay: 1s; } .snow:nth-of-type(11) { top: 4px; left: 2px; -webkit-animation-delay: 5s; animation-delay: 5s; } .snow:nth-of-type(12) { top: 9px; left: 18px; -webkit-animation-delay: 6s; animation-delay: 6s; } .snow:nth-of-type(13) { top: 12px; left: 37px; -webkit-animation-delay: 2s; animation-delay: 2s; } .snow:nth-of-type(14) { top: 10px; left: 65px; -webkit-animation-delay: 3s; animation-delay: 3s; } .snow:nth-of-type(15) { top: 13px; left: 32px; -webkit-animation-delay: 8s; animation-delay: 8s; } .snow:nth-of-type(16) { top: 2px; left: 51px; -webkit-animation-delay: 4s; animation-delay: 4s; } .snow:nth-of-type(17) { top: 30px; left: 36px; -webkit-animation-delay: 1s; animation-delay: 1s; } .snow:nth-of-type(18) { top: 13px; left: 46px; -webkit-animation-delay: 8s; animation-delay: 8s; } .snow:nth-of-type(19) { top: 4px; left: 68px; -webkit-animation-delay: 2s; animation-delay: 2s; } .snow:nth-of-type(20) { top: 8px; left: 63px; -webkit-animation-delay: 7s; animation-delay: 7s; } .rain { opacity: 0; display: none; background-color: #eaf9fe; width: 4px; height: 8px; -webkit-transform: rotate(-30deg); transform: rotate(-30deg); border-color: #eaf9fe; border-top-left-radius: 50%; border-bottom-left-radius: 50%; border-bottom-right-radius: 50%; -webkit-transition: 2s ease all; transition: 2s ease all; -webkit-animation: drops 1s linear infinite; animation: drops 1s linear infinite; } .rain:nth-child(1) { top: 7px; left: 22px; -webkit-animation-delay: 0.1s; animation-delay: 0.1s; } .rain:nth-child(2) { top: 6px; left: 7px; -webkit-animation-delay: 0.2s; animation-delay: 0.2s; } .rain:nth-child(3) { top: 13px; left: 59px; -webkit-animation-delay: 0.3s; animation-delay: 0.3s; } .rain:nth-child(4) { top: 14px; left: 9px; -webkit-animation-delay: 0.4s; animation-delay: 0.4s; } .rain:nth-child(5) { top: 17px; left: 56px; -webkit-animation-delay: 0.5s; animation-delay: 0.5s; } .rain:nth-child(6) { top: 9px; left: 48px; -webkit-animation-delay: 0.6s; animation-delay: 0.6s; } .rain:nth-child(7) { top: 25px; left: 7px; -webkit-animation-delay: 0.7s; animation-delay: 0.7s; } .rain:nth-child(8) { top: 24px; left: 22px; -webkit-animation-delay: 0.8s; animation-delay: 0.8s; } .rain:nth-child(9) { top: 14px; left: 22px; -webkit-animation-delay: 0.9s; animation-delay: 0.9s; } .rain:nth-child(10) { top: 22px; left: 27px; -webkit-animation-delay: 1s; animation-delay: 1s; } .rain:nth-child(11) { top: 8px; left: 17px; -webkit-animation-delay: 1.1s; animation-delay: 1.1s; } .rain:nth-child(12) { top: 20px; left: 15px; -webkit-animation-delay: 1.2s; animation-delay: 1.2s; } .rain:nth-child(13) { top: 14px; left: 31px; -webkit-animation-delay: 1.3s; animation-delay: 1.3s; } .rain:nth-child(14) { top: 13px; left: 58px; -webkit-animation-delay: 1.4s; animation-delay: 1.4s; } .rain:nth-child(15) { top: 14px; left: 30px; -webkit-animation-delay: 1.5s; animation-delay: 1.5s; } .rain:nth-child(16) { top: 27px; left: 58px; -webkit-animation-delay: 1.6s; animation-delay: 1.6s; } .rain:nth-child(17) { top: 17px; left: 57px; -webkit-animation-delay: 1.7s; animation-delay: 1.7s; } .rain:nth-child(18) { top: 2px; left: 45px; -webkit-animation-delay: 1.8s; animation-delay: 1.8s; } .rain:nth-child(19) { top: 23px; left: 60px; -webkit-animation-delay: 1.9s; animation-delay: 1.9s; } .rain:nth-child(20) { top: 4px; left: 14px; -webkit-animation-delay: 2s; animation-delay: 2s; } .rain:nth-child(21) { top: 26px; left: 1px; -webkit-animation-delay: 2.1s; animation-delay: 2.1s; } .rain:nth-child(22) { top: 2px; left: 14px; -webkit-animation-delay: 2.2s; animation-delay: 2.2s; } .rain:nth-child(23) { top: 11px; left: 11px; -webkit-animation-delay: 2.3s; animation-delay: 2.3s; } .rain:nth-child(24) { top: 13px; left: 68px; -webkit-animation-delay: 2.4s; animation-delay: 2.4s; } .rain:nth-child(25) { top: 1px; left: 55px; -webkit-animation-delay: 2.5s; animation-delay: 2.5s; } .rain:nth-child(26) { top: 19px; left: 20px; -webkit-animation-delay: 2.6s; animation-delay: 2.6s; } .rain:nth-child(27) { top: 12px; left: 62px; -webkit-animation-delay: 2.7s; animation-delay: 2.7s; } .rain:nth-child(28) { top: 14px; left: 27px; -webkit-animation-delay: 2.8s; animation-delay: 2.8s; } .rain:nth-child(29) { top: 19px; left: 46px; -webkit-animation-delay: 2.9s; animation-delay: 2.9s; } .rain:nth-child(30) { top: 25px; left: 35px; -webkit-animation-delay: 3s; animation-delay: 3s; } @-webkit-keyframes drops { 0% { opacity: 0; -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } 5% { opacity: 1; } 80% { opacity: 1; } 100% { -webkit-transform: translate3d(20px, 200px, 0); transform: translate3d(20px, 200px, 0); opacity: 0; } } @keyframes drops { 0% { opacity: 0; -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } 5% { opacity: 1; } 80% { opacity: 1; } 100% { -webkit-transform: translate3d(20px, 200px, 0); transform: translate3d(20px, 200px, 0); opacity: 0; } } @-webkit-keyframes snow { 0% { margin-top: 0px; opacity: 0; } 5% { opacity: 1; } 50% { opacity: 1; margin-left: 20px; } 100% { margin-top: 200px; opacity: 0; } } @keyframes snow { 0% { margin-top: 0px; opacity: 0; } 5% { opacity: 1; } 50% { opacity: 1; margin-left: 20px; } 100% { margin-top: 200px; opacity: 0; } } .cloud:nth-child(2) { left: 70px; top: 65px; width: 90px; } .cloud:nth-child(3) { left: 330px; top: 30px; width: 80px; height: 25px; } .cloud:nth-child(4) { left: 290px; top: 60px; width: 90px; } .cloud:nth-child(5) { left: 480px; top: 40px; width: 100px; } .cloud:nth-child(6) { left: 580px; top: 80px; } .cloud:nth-child(7) { left: 520px; top: 105px; width: 110px; } .cloud:nth-child(8) { left: 660px; top: 160px; width: 70px; } .base { width: 650px; height: 20px; left: 80px; background-color: var(--bush); border-radius: 20px; bottom: 50px; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); } .bush-group { width: 100%; height: 100%; bottom: 5px; left: 0; } .bush { z-index: 100; width: 90px; height: 40px; bottom: 0px; left: 0; background-color: var(--bush); border-radius: 50px 50px 0 0; } .bush:nth-child(2) { left: 70px; } .bush:nth-child(3) { left: 140px; } .bush:nth-child(4) { left: 210px; } .bush:nth-child(5) { left: 280px; } .bush:nth-child(6) { left: 350px; } .bush:nth-child(7) { left: 420px; } .bush:nth-child(8) { left: 490px; } .bush:nth-child(9) { left: 560px; } .tree-group { width: 100%; height: 350px; bottom: 0px; left: 0; } .tree { z-index: 1; bottom: 10px; width: 5px; height: 50px; left: 10px; } .tree .tree-top { background-color: var(--dark); border-radius: 100%; top: -30px; width: 40px; height: 40px; left: -20px; } .tree .tree-top:after { content: ""; position: absolute; width: 80%; height: 80%; top: 5%; right: 5%; background-color: var(--medium); border-radius: 100%; } .tree .trunk { background-color: var(--trunk); width: 100%; height: 100%; border-radius: 10px; } .tree:nth-child(1) .trunk, .tree:nth-child(2) .trunk, .tree:nth-child(3) .trunk, .tree:nth-child(6) .trunk, .tree:nth-child(7) .trunk, .tree:nth-child(8) .trunk, .tree:nth-child(11) .trunk, .tree:nth-child(12) .trunk { background-color: var(--trunk2); } .branch { z-index: -1; height: 10px; width: 40px; border-radius: 10px; background-color: var(--dark); -webkit-transform: rotate(30deg); transform: rotate(30deg); -webkit-transform-origin: 0% 0%; transform-origin: 0% 0%; left: 5px; } .branch-two { top: 70px; height: 20px; width: 40px; border-radius: 0 0 20px 0; border: 7px solid var(--trunk); border-left: 0; border-top: 0; } .branch-two .tree-top { width: 50px; height: 20px; top: -10px; left: 20px; } .tree:nth-child(2) { left: 40px; height: 70px; width: 6px; z-index: 2; } .tree:nth-child(2) .tree-top { background-color: var(--medium); top: -35px; width: 50px; height: 50px; left: -23px; } .tree:nth-child(2) .tree-top:after { background-color: var(--light); } .tree:nth-child(3) { left: 80px; height: 50px; } .tree:nth-child(3) .tree-top { background-color: var(--medium); top: -15px; width: 30px; height: 30px; left: -13px; } .tree:nth-child(3) .tree-top:after { background-color: var(--li.........完整代码请登录后点击上方下载按钮下载查看
网友评论0