js+css实现经典带点击声效计算器代码
代码语言:html
所属分类:其他
代码描述:js+css实现经典带点击声效计算器代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url("https://fonts.googleapis.com/css2?family=Abril+Fatface&display=swap"); /* Seven segment * from https://www.kraftilab.com/ */ @font-face { font-family: "Seven Segment"; src: url("//repo.bfw.wiki/bfwrepo/font/Seven+Segment.ttf"); } @font-face { font-family: "Mona Sans"; src: url("//repo.bfw.wiki/bfwrepo/font/Mona-Sans.woff2") format("woff2 supports variations"), url("//repo.bfw.wiki/bfwrepo/font/Mona-Sans.woff2") format("woff2-variations"); font-weight: 100 1000; } @supports (background: paint(something)) { @layer properties { @property --base-hue { syntax: "<number>"; inherits: true; initial-value: 0; } @property --gradient-start { syntax: "<color>"; inherits: true; initial-value: 0; } @property --gradient-stop { syntax: "<color>"; inherits: true; initial-value: 0; } @property --box-shadow-1 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --box-shadow-2 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --box-shadow-3 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --box-shadow-4 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --box-shadow-5 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --inner-background-start { syntax: "<color>"; inherits: true; initial-value: 0; } @property --inner-background-stop { syntax: "<color>"; inherits: true; initial-value: 0; } @property --inner-box-shadow-1 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --inner-box-shadow-2 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --inner-box-shadow-3 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --inner-box-shadow-4 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --screen-box-shadow-1 { syntax: "<color>"; inherits: true; initial-value: 0; } @property --screen-box-shadow-2 { syntax: "<color>"; inherits: true; initial-value: 0; } } } :root { --debug: 0; --bg-color: oklch(97.02% 0 0); } *, *:before, *:after { box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; outline: calc(var(--debug) * 1px) dotted hsl(calc(var(--debug) * 10 * 1deg), 60%, 60%); } html, body, main { width: 100%; height: 100%; margin: 0; padding: 0; } body { background-color: #f5f5f5; background-image: conic-gradient(from 90deg at 1px 1px, transparent 90deg, rgba(0, 0, 0, 0.1) 0); background-size: 8vw 8vw; font-family: "Mona Sans", sans-serif; transition: --gradient-start 0.2s ease, --gradient-stop 0.2s ease, --box-shadow-1 0.2s ease, --box-shadow-2 0.2s ease, --box-shadow- 0.2s ease, --box-shadow-4 0.2s ease, --box-shadow-5 0.2s ease, --inner-background-start 0.2s ease, --inner-background-stop 0.2s ease, --inner-box-shadow-1 0.2s ease, --inner-box-shadow-2 0.2s ease, --inner-box-shadow-3 0.2s ease, --inner-box-shadow-4 0.2s ease, --screen-box-shadow-1 0.2s ease, --screen-box-shadow-2 0.2s ease; } body:before { content: ""; display: block; position: absolute; width: 100%; height: 100%; background: radial-gradient(circle at 50% 50%, transparent 50%, rgba(7, 8, 24, 0.4)); } main { display: grid; place-items: center; grid-template-columns: repeat(1, 1fr); grid-template-rows: repeat(1, 1fr); align-items: center; justify-content: center; } main .calculator { transform: scale(1); } .calculator { --base-hue: 44; --base-saturation: 91; --base-lightness: 55; --gradient-start: hsl( var(--base-hue), calc(var(--base-saturation) * 1%), calc(var(--base-lightness) * 1%) ); --gradient-stop: hsl( var(--base-hue), calc(calc(var(--base-saturation) - 6) * 1%), calc(calc(var(--base-lightness) + 13) * 1%) ); --box-shadow-1: hsla( calc(var(--base-hue) - 10), 16%, 51%, 80% ); /* light gray */ --box-shadow-2: hsla( calc(var(--base-hue) - 10), 16%, 51%, 80% ); /* light gray */ --box-shadow-3: hsla( calc(var(--base-hue) - 10), 34%, 31%, 80% ); /* dark gray */ --box-shadow-4: hsl(var(--base-hue), 100%, 89%); --box-shadow-5: hsla(calc(var(--base-hue) - 10), 92%, 48%, 80%); --inner-background-start: hsl( var(--base-hue), 91%, calc(var(--base-lightness) * 1%) ); --inner-background-stop: hsl( var(--base-hue), 85%, calc(calc(var(--base-lightness)+13) * 1%) ); --inner-box-shadow-1: hsl( var(--base-hue), 100%, calc(calc(var(--base-lightness) + 26) * 1%) ); --inner-box-shadow-2: hsl( calc(var(--base-hue) - 5), 93%, calc(calc(var(--base-lightness) - 3) * 1%) ); --inner-box-shadow-3: hsl( calc(var(--base-hue) - 20), 88%, calc(calc(var(--base-lightness) - 27) * 1%) ); --inner-box-shadow-4: hsl( var(--base-hue), 100%, calc(calc(var(--base-lightness) + 34) * 1%) ); --screen-background-start: hsl(30, 22%, 30%); --screen-background-stop: hsl(31, 22%, 34%); --screen-box-shadow-1: hsl( var(--base-hue) 83% calc(calc(var(--base-lightness) - 10) * 1%) ); --screen-box-shadow-2: hsl(calc(var(--base-hue) - 10) 47% 22%); --screen-font-color: hsl(24, 64%, 28%); width: 286px; aspect-ratio: 57.2/85; background: linear-gradient(0.17deg, var(--gradient-start) 0.23%, var(--gradient-stop) 99.93%); box-shadow: -9px 14px 28px -7px var(--box-shadow-1), 9px 14px 28px -7px var(--box-shadow-2), 0px 22px 6px -10px var(--box-shadow-3), inset 0px 1px 1px var(--box-shadow-4), inset 0px -1px 2px var(--box-shadow-5); border-radius: 26px 26px 51px 51px; padding: 8px; } .calculator > div { display: flex; align-items: start; justify-content: center; flex-direction: column; padding: 14px; width: 100%; height: 100%; background: linear-gradient(0.17deg, var(--inner-background-start) 0.23%, ver(--inner-background-stop) 99.93%); box-shadow: 0px 2px 1px var(--inner-box-shadow-1), 0px -1px 2px var(--inner-box-shadow-2), inset 0px -1px 2px var(--inner-box-shadow-3), inset 0px 2px 2px var(--inner-box-shadow-4), inset 0 0 1px rgba(0, 0, 0, 0.15); border-radius: 19px 19px 43px 43px; } .calculator > div span:has(button) { display: flex; align-items: center; justify-content: center; } .calculator > div .screen { font-family: "Seven Segment", courier; width: 242px; height: 54px; background: linear-gradient(89.89deg, var(--screen-background-start) 0.08%, var(--screen-background-stop) 99.9%); box-shadow: 0px -1px 1px var(--screen-box-shadow-1), inset 0px 12px 4px -6px var(--screen-box-shadow-2), inset 0 -2px 1px color-mix(in srgb, var(--gradient-start), white 40%); border-radius: 8px; position: relative; font-style: normal; font-weight: 400; font-size: 37.1429px; font-feature-settings: "tnum"; text-align: center; overflow: hidden; } @supports not (color: color-mix(in srgb, red, blue)) { .calculator > div .screen { box-shadow: 0px -1px 1px var(--screen-box-shadow-1), inset 0px 12px 4px -6px var(--screen-box-shadow-2), inset 0 -1px 1px rgba(255, 255, 255, 0.2); } } .calculator > div .screen:before { content: "000000000000"; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute; filter: blur(1.........完整代码请登录后点击上方下载按钮下载查看
网友评论0