svg+gsap实现带音效昼夜切换动画效果代码
代码语言:html
所属分类:动画
代码描述:svg+gsap实现带音效昼夜切换动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
*,
*:after,
*:before {
box-sizing: border-box;
}
:root {
--size: calc(2 * 48px);
--sun: #f7c96e;
--sun-ray--even: #f6c155;
--sun-ray--odd: #f9d286;
--eye: #1a1a1a;
--accent: #e84f30;
--beak-left: #e6b319;
--beak-right: #ebc247;
--body: #fff;
--hill-one: #73bf40;
--hill-two: #4b9933;
}
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: hsl(210, 0%, calc((5 + (var(--on, 0) * 80)) * 1%));
}
body::before {
--size: 60px;
--line: color-mix(in lch, canvasText, transparent 90%);
content: '';
height: 100vh;
width: 100vw;
position: fixed;
background: linear-gradient(
90deg,
var(--line) 1px,
transparent 1px var(--size)
)
50% 50% / var(--size) var(--size),
linear-gradient(var(--line) 1px, transparent 1px var(--size)) 50% 50% /
var(--size) var(--size);
-webkit-mask: linear-gradient(-15deg, transparent 50%, white);
mask: linear-gradient(-15deg, transparent 50%, white);
top: 0;
transform-style: flat;
pointer-events: none;
z-index: -1;
}
button {
height: var(--size);
width: var(--size);
padding: 0;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: 0;
background: none;
cursor: pointer;
border-radius: 50%;
}
button:focus-visible {
outline: 2px solid canvasText;
outline-offset: 2px;
}
span {
display: none;
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
:root:has([aria-pressed=true]) {
color-scheme: light only;
}
:root:has([aria-pressed=false]) {
color-scheme: dark only;
}
[aria-pressed="true"] span:nth-of-type(1) {
display: none;
}
[aria-pressed="true"] span:nth-of-type(2) {
display: inline-block;
}
[aria-pressed="false"] span:nth-of-type(1) {
display: inline-block;
}
[aria-pressed="false"] span:nth-of-type(2) {
display: none;
}
.cockerel__eye {
fill: var(--eye);
}
.cockerel__body {
fill: var(--body);
}
.cockerel__beak--left {
fill: var(--beak-left);
}
.cockerel__beak--right {
fill: var(--beak-right);
}
.cockerel__comb path,
.cockerel__wattle {
fill: var(--accent);
}
.hill:nth-of-type(1) {
fill: var(--hill-one);
}
.hill:nth-of-type(2) {
fill: var(--hill-two);
}
.sun {
fill: var(--sun);
}
.sun__ray-holder:nth-of-type(even) {
--fill: var(--sun-ray--even);
}
.sun__ray-holder:nth-of-type(odd) {
--fill: var(--sun-ray--odd);
}
.sun__ray {
fill: var(--fill);
}
.scene {
height: 100%;
width: 100%;
overflow: visible !important;
display: none;
}
.scene__backdrop {
fill: hsl(207, 88%, calc((22 + (va.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0