css实现北极光晕效果
代码语言:html
所属分类:背景
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { box-sizing: border-box; } :root { --hue: 220; } body { background: hsl(var(--hue),100%, 5%); height: 100vh; overflow: hidden; } .star { --hue: 55; border-radius: 50%; background: hsl(var(--hue),100%, 50%); box-shadow: 0 0 5px 1px hsl(var(--hue), 100%, 85%); height: calc(var(--size,2) * 1px); position: absolute; width: calc(var(--size,2) * 1px); left: calc(var(--x,0) * 1vw); opacity: 0.5; top: calc(var(--y,0) * 1vw); -webkit-animation: flicker calc(var(--duration, 2) * 1s) calc(var(--delay, 10) * 1s) infinite steps(1); animation: flicker calc(var(--duration, 2) * 1s) calc(var(--delay, 10) * 1s) infinite steps(1); } .hill { background: hsl(var(--hue),100%, 2%); position: fixed; bottom: 0; left: 0; height: 25vmin; width: 68vmin; border-radius: 0 100% 0 0; } .hill:after { content: ''; position: absolute; height: 15vmin; width: 50vmax; background: hsl(var(--hue),100%, 2%); left: 0; bottom: 0; border-radius: 0 100% 0 0; } .moon { height: 40vmin; width: 40vmin; position: absolute; left: 0; top: 0; background: #c6b9b9; border-radius: 50%; box-shadow: 0 0 50px 10px #8c8c8c; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); -webkit-filter: blur(10px); filter: blur(10px); } .lights { width: 200vmax; height: 100vmax; position: absolute; left: 50%; top: 0; -webkit-transform: translate(-20%, -55%) rotate(30deg); transform: translate(-20%, -55%) rotate(30deg); display: -webkit-box; display: flex; -webkit-filter: blur(75px); filter: blur(75px); } .light { -webkit-box-flex: 1; flex: 1; --color-one: hsla(var(--hue-1),100%, 50%, var(--alpha-1)); --color-two: hsla(var(--hue-2),100%, 50%, var(--alpha-2)); --color-three: hsla(var(--hue-3),100%, 50%, var(--alpha-3)); --up: calc(var(--y,10) * 1vmax); --left: calc(var(--x,2) * 1vmax); background-image: -webkit-gradient(linear, left bottom, left top, from(transparent), color-stop(10%, var(--color-one)), color-stop(transparent), color-stop(40%, var(--color-two)), color-stop(transparent), color-stop(60%, var(--color-three))); background-image: linear-gradient(0deg, transparent, var(--color-one) 10%, transparent, var(--color-two) 40%, transparent, var(--color-three) 60%); background-size: 100% 40vmax; background-position: center bottom; background-repeat: no-repeat; -webkit-transform: translate(var(--left), var(--up)) scale(1); transform: translate(var(--left), var(--up)) scale(1); -webkit-animation: shift calc(var(--duration, 2) * 1s) calc(var(--delay, 0) * -1s) infinite ease; animation: shift calc(var(--duration, 2) * 1s) calc(var(--delay, 0) * -1s) infinite ease; } @media (max-width: 768px) { .light { --up: calc(var(--y,10) * 2vmax); --left: calc(var(--x,2) * 2vmax); } } @-webkit-keyframes shift { 50% { -webkit-transform: translate(0, 0) scale(1); transform: translate(0, 0) scale(1); } } @keyframes shift { 50% { -webkit-transform: translate(0, 0) scale(1); transform: translate(0, 0) scale(1); } } @-webkit-keyframes flicker { 0%, 50%, 100% { -webkit-transform: scale(1); transform: scale(1); } 25% { -webkit-transform: scale(0); transform: scale(0); } } @keyframes flicker { 0%, 50%, 100% { -webkit-transform: scale(1); transform: scale(1); } 25% { -webkit-transform: scale(0); transform: scale(0); } } </style> </head> <body translate="no"> <div class="scene" style="--hue-1: 223; --hue-2: 220; --hue-3: 184; --alpha-1: 0.909084327464345; --alpha-2: 0.1977257436773674; --alpha-3: 0.9759370573273878;"> <div class="star" style="--size: 1.4821042985693094; --x: 11.412651479872139; --y: 15.394088574090903; --duration: 10; --delay: 9;"></div> <div class="star" style="--size: 0.08633833770763122; --x: 66.22176906061026; --y: 43.97014601938017; --duration: 7; --delay: 10;"></div> <div class="star" style="--size: 0.11181393317191635; --x: 34.71979099204206; --y: 76.2019095006377; --duration: 6; --delay: 5;"></div> <div class="star" style="--size: 0.2402461534235396; --x: 31.945485400110286; --y: 41.30739730586113; --duration: 9; --delay: 10;"></div> <div class="star" style="--size: 1.2578018684194134; --x: 95.18983659079929; --y: 0.16737470924030884; --duration: 6; --delay: 9;"></div> <div class="star" style="--size: 0.37758201515759415; --x: 41.972001777366906; --y: 7.598016791868201; --duration: 6; --delay: 10;"></div> <div class="star" style="--size: 0.8237694366579547; --x: 48.480320102430994; --y: 5.640614026489388; --duration: 10; --delay: 5;"></div> <div class="star" style="--size: 0.2951150865392087; --x: 89.78392384852607; --y: 50.93419287221097; --duration: 10; --delay: 10;"></div> <div class="star" style="--size: 1.5425088334281583; --x: 55.42568940262713; --y: 18.848971935424785; --duration: 6; --delay: 10;"></div> <div class="star" style="-.........完整代码请登录后点击上方下载按钮下载查看
网友评论0