css+jquery实现可自定义的立体按钮代码
代码语言:html
所属分类:布局界面
代码描述:css+jquery实现可自定义的立体按钮代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,300;0,500;0,600;1,300;1,500;1,600&display=swap'> <style> :root { --hue: 190deg; --sat: 60%; } #app div { --hue2: calc(var(--hue) + 60deg); --sat2: calc(var(--sat) - 10%); --clr: hsl(var(--hue) var(--sat) 90%); --clr2: hsl(var(--hue2) var(--sat2) 85%); --text: hsla(var(--hue2), 50%, 25%, 0.75); --gradoffset: 50%; --gradgap: 30%; } #app .custom { --hue: 30deg; --sat: 50%; --hue2: 5deg; --sat2: 80%; } button { font-size: 6vw; color: var(--text); font-weight: 600; letter-spacing: -0.025em; text-shadow: 0 1px 1px hsla(var(--hue), 100%, 95%, 1); background-color: var(--clr); background-image: linear-gradient(180deg, var(--clr2) var(--gradgap), transparent calc(100% - var(--gradgap))); background-repeat: no-repeat; background-position: center var(--gradoffset); background-size: 100% 200%; padding: 1em 1.5em; border-radius: 2em; border: none; box-shadow: 0 -0.5em 0.5em transparent, 0 0.5em 0.5em transparent, 0 0.25em 0.3em -0.2em hsla(var(--hue), var(--sat), 50%, 0.46), 0 0.25em 0.75em hsla(var(--hue), calc(var(--sat) - 10%), 40%, 0.3); position: relative; transition: all 0.5s ease; outline: none; } @media screen and (min-width: 400px) { button { font-size: 3vw; } } button::before, button::after { content: ""; inset: 0; position: absolute; border-radius: 5em; } button::before { background-image: linear-gradient(90deg, black -10%, transparent 30%, transparent 70%, black 110%); box-shadow: inset 0 0.25em 0.75em rgba(0, 0, 0, 0.8), inset 0 -0.05em 0.2em rgba(255, 255, 255, 0.4), inset 0 -1px 3px hsla(var(--hue), 80%, 50%, 0.75); mix-blend-mode: overlay; } button::after { background: linear-gradient(180deg, white, hsla(var(--hue2), 100%, 60%, 1) 50%, transparent 80%); top: 0.075em; left: 0.75em; right: 0.75em; bottom: 1.4em; opacity: 0.7; filter: blur(0.5px); mix-blend-mode: screen; } button:hover, button:active, button:focus { outline: none; box-shadow: 0 -0.5em 1.5em hsla(var(--hue2), 70%, 80%, 0.3), 0 0.5em 1.5em hsla(var(--hue), 70%, 80%, 0.5), 0 0.25em 0.3em -0.2em hsl(var(--hue), 90%, 70%), 0 0.25em 0.5em hsla(var(--hue), 20%, 30%, 0.2), inset 0 -2px 2px rgba(255, 255, 255, 0.2); background-position: center calc( var(--gradoffset) - 0.75em ); } .static button { position: relative; } .static button .spinner { position: absolute; left: 50%; top: 50%; transform: translateY(0.75em) translateX(-50%); opacity: 0; margin: 0; font-size: 2em; mix-blend-mode: overlay; } .static button span, .static button svg, .static button .spinner { transition: all 0.33s ease; } .static button:active span, .static button:active svg:not(.spinner), .static button:focus span, .static button:focus svg:not(.spinner) { transform: translateY(-1em); opacity: 0; filter: blur(5px); } .static button:active .spinner, .static button:focus .spinner { transform: translateY(-0.5em) translateX(-50%); opacity: 1; } body { color: white; background: #3b3d4c; font-family: "Noto Sans", sans-serif; font-weight: 200; padding: 2vw; text-align: center; } button { font-family: "Noto Sans", sans-serif; display: flex; } svg { height: 1em; width: auto; margin-left: 0.33em; } button svg, button span { display: inline-flex; align-content: center; align-self: center; } #app { display: grid; gap: 2vw; } @media screen and (min-width: 400px) { #app { grid-template-columns: auto auto; grid-template-rows: -webkit-min-content auto -webkit-max-content; grid-template-rows: min-content auto max-content; } } h1, p { grid-column: 1/-1; } #app > div { position: relative; border-radius: 2vw; min-height: 200px; background-color: hsl(var(--hue), 20%, 95%); background-image: linear-gradient(33deg, transparent 60%, var(--clr)), linear-gradient(210deg, transparent 60%, var(--clr2)); background-size: 150%; background-position: center; display: flex; align-items: center; justify-content: center; box-shadow: rgba(0, 0, 0, 0.15) 0px 15px 25px, rgba(0, 0, 0, 0.05) 0px 5px 10px; } body, html, #app { height: 100%; box-sizing: border-box; } a { color: #6adcf6; } input[type=range] { position: absolute; top: 1em; left: 0.5em; right: 0.5em; width: auto; max-width: 40%; } #hue1 { top: auto; bottom: 1em; } #sat1 { top: auto; bottom: 1em; left: auto; } #sat2 { left: auto; } #grad { left: auto; top: 50%; transform: translateY(-50%); } #gradoff { top: 50%; transform: translateY(-50%); } input { font-family: inherit; color: white; background: #3b3d4c; padding: 0.875em; border-radius: 8px; border: 1px solid transparent; outline: 1px solid transparent; accent-color: var(--clr); box-shadow: 0 3px 2px -3px var(--clr); transition: border 0.3s ease-in, outline 0.6s ease-in, box-shadow 0.6s ease-in; } input:focus { border-color: var(--clr2); outline-color: var(--clr2); transition: border 0.6s ease-out, outline 0.3s ease-out, box-shadow 0.3s ease-out; } input::-moz-placeholder { opacity: 0.33; font-style: italic; } input:-ms-input-placeholder { opacity: 0.33; font-style: italic; } input::placeholder { opacity: 0.33; font-style: italic; } input[type=range] { -webkit-appearance: none; -moz-appearance: none; appearance: none; height: calc(1em + 2px * 2); background: #3b3d4c; border: none; outline: none; padding: 0 5px; margin-inline: 0.5em; border-radius: 1em; } input[type=range], input[type=range]* { transition: all 0.5s ease; } input[type=range]::-webkit-slider-runnable-track { background: #3b3d4c; display: block; width: calc(100% + 5px * 2); height: calc(1em + 5px * 2); border-radius: 1em; margin-inline: calc(5px * -1); -webkit-transition: opacity 0.5s ease-in, background 0.5s ease-in; transition: opacity 0.5s ease-in, background 0.5s ease-in; opacity: 0; will-change: opacity, background; background: #3b3d4c; padding: 0.25em 5px; opacity: 1; } input[type=range]::-moz-range-track { background: #3b3d4c; display: block; width: calc(100% + 5px * 2); height: calc(1em + 5px * 2); border-radius: 1em; margin-inline: calc(5px * -1); -moz-transition: opacity 0.5s ease-in, background 0.5s ease-in; transition: opacity 0.5s ease-in, background 0.5s ease-in; opacity: 0; will-change: opacity, background; } input[type=range]::-ms-track { background: #3b3d4c; display: block; width: calc(100% + 5px * 2); height: calc(1em + 5px.........完整代码请登录后点击上方下载按钮下载查看
网友评论0