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