css+svg实现带夜晚模式的毛玻璃计算器ui效果代码
代码语言:html
所属分类:布局界面
代码描述:css+svg实现带夜晚模式的毛玻璃计算器ui效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: flex; justify-content: center; align-items: center; background-color: #AB61E4; min-height: 100vh; overflow: hidden; color: #fff; } .calculator { --header-bg: rgba(255,255,255,.2); --body-bg: rgba(255,255,255,.3); --button-bg: rgba(255,255,255,.2); --button-bg-hover: rgba(255,255,255,.3); --button-highlight-bg: rgba(255,255,255,.5); --button-highlight-bg-hover: rgba(255,255,255,.3); transition: all 0.8s cubic-bezier(0.075, 0.82, 0.165, 1) 0s; position: relative; width: 280px; box-shadow: rgba(24, 32, 79, 0.25) 0px 40px 80px, rgba(255, 255, 255, 0.5) 0px 0px 0px 0.5px inset; border-radius: 15px; z-index: 10; } .calculator:hover { margin-bottom: 5px; } .calculator:hover ~ .calculator-back { transform: skewY(18deg); width: 35%; } .calculator.dark { --header-bg: rgba(2,14,39,.2); --body-bg: rgba(2,14,39,.3); --button-bg: rgba(2,14,39,.2); --button-bg-hover: rgba(255,255,255,.1); --button-highlight-bg: rgba(2,14,39,.5); --button-highlight-bg-hover: rgba(255,255,255,.15); } .calculator-header { position: relative; background-color: var(--header-bg); padding: 30px 30px 15px 30px; text-align: right; border-top-left-radius: 15px; border-top-right-radius: 15px; -webkit-backdrop-filter: blur(40px); backdrop-filter: blur(40px); box-shadow: inset 0px 2px 1px rgba(255, 255, 255, 0.1); } .calculator-body { position: relative; background-color: var(--body-bg); padding: 15px; border-bottom-left-radius: 15px; border-bottom-right-radius: 15px; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); min-height: 250px; } .calculator-operation { font-size: 18px; margin-bottom: 4px; } .calculator-operation-result { font-size: 42px; font-weight: bold; } .calculator-button { position: relative; display: block; height: 100%; border: 1px solid transparent; background-color: var(--button-bg); font-size: 20px; cursor: pointer; color: #fff; border: 1px solid rgba(255, 255, 255, 0); -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: all 0.2s ease-in-out; will-change: auto; z-index: 2; } .calculator-button:hover, .calculator-button:focus { box-shadow: 0px 10px 25px rgba(4, 37, 100, 0.12); border-radius: 4px; background-color: var(--button-bg-hover); border-color: rgba(255, 255, 255, 0.15); z-index: 5; transform: scale(1.35); } .calculator-button:focus { outline: none; } .calculator-button.equal { grid-row-start: span 2; grid-column-start: 4; } .calculator-button.highlight { background-color: var(--button-highlight-bg); } .calculator-button.highlight:hover, .calculator-button.highlight:focus { background-color: var(--button-highlight-bg-hover); } .calculator-button-wrapper { position: absolute; top: calc(117px + 15px); right: 15px; bottom: 15px; left: 15px; display: grid; grid-gap: 2px; grid-template-columns: repeat(4, auto); grid-template-rows: repeat(5, 45px); } .calculator-back { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 85%; background-image: linear-gradient(#bd1d8c 0%, #7a41ce 100%); border-radius: 15px; transform: skewY(8deg); transform-origin: left top; transition: all 0.8s cubic-bezier(0.075, 0.82, 0.165, 1) 0s; z-index: 5; } .calculator-wrapper { position: relative; } .title { position: absolute; top: 0; right: 0; bottom: 0; left: 0; font-size: calc(62px + 1vw); font-weight: 900; color: #1f3e5a; letter-spacing: -0.065em; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .title:nth-child(2) { mix-blend-mode: screen; opacity: 0.75; } .title-wrapper { position: absolute; top: 100%; left: 0; transform: rotate(-90deg) translate(-80px, -65px); mix-blend-mode: difference; -webkit-backdrop-filter: opacity(1); backdrop-filter: opacity(1); z-index: 10; } .bg-item { position: absolute; } .toggle-theme { position: absolute; top: 0; left: 0; font-size: 13px; padding: 8px 12px; background-color: var(--button-bg); border-top-left-radius: 15px; border-bottom-right-radius: 15px; color: #fff; cursor: pointer; border: none; outline: none; will-change: auto; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); transition: all 0.1s ease-in-out; z-index: 5; } .toggle-theme:hover, .toggle-theme:focus { box-shadow: 0px 10px 25px rgba(4, 37, 100, 0.12); border: 1px solid rgba(255, 255, 255, 0.2); background-color: var(--button-bg-hover); border-color: rgba(255, 255, 255, 0.08); transform: scale(1.25); } #bg-1 { filter: blur(10px); } #bg-2 { filter: blur(36px); } #bg-4 { filter: blur(50px); } #bg-6 { filter: blur(40px); } #bg-7 { filter: blur(30px); } #bg-9 { filter: blur(20px); } </style> </head> <body > <div id="bg-0" class="bg-item" style="top: 0; right: 0; bottom: 0; left: 0;"> <svg width="100%" height="100%" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect y="0.4375" width="100%" height="100%" fill="#AB61E4"/> </svg> </div> <div id="bg-1" class="bg-item" style="bottom: 0; left: 0;"> <svg width="371" height="476" viewBox="0 0 371 476" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M371 0H-60V538H371V0Z" fill="#F56CF0"/> </svg> </div> <div id="bg-2" class="bg-item" style="bottom: -15%; right: calc(35% - 217px);"> <svg width="478" height="430" viewBox="0 0 478 430" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M523 0H0V480H523V0Z" fill="#D2578B"/> </svg> </div> <div id="bg-3" class="bg-item" style="bottom: 20%; left: 15%;"> <svg width="254" height="211" viewBox="0 0 254 211" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M254 0H0V211H254V0Z" fill="#F56CF0"/> </svg> </div> <div id="bg-4" class="bg-item" style="top: 0; right: 0; bottom: 0;"> <svg width="332" height="600" viewBox="0 0 332 600" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M338.5 -169L676.68 26V416L338.5 611L0.316986 416V26L338.5 -169Z" fill="#AB61E4"/> </svg> </div> <div id="bg-5" class="bg-item" style="bottom: 20%; right: 3%;"> <svg width="299" height="344" viewBox="0 0 299 344" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M149.5 0L298.889 86V258L149.5 344L0.110992 258V86L149.5 0Z" fill="#AB61E4"/> </svg> </div> <div id="bg-6" class="bg-item" style="top: 0; left: calc(50% - 281px);"> <svg width="563" height="393" viewBox="0 0 563 393" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M281.5 393C436.968 393 563 270.774 563 120C563 -30.7737 436.968 -153 281.5 -153C126.032 -153 0 -30.7737 0 120C0 270.774 126.032 393 281.5 393Z" fill="#7A8DF4"/> </svg> </div> <div id="bg-7" class="bg-item" style="top: 0; left: 0"> <svg width="454" height="329" viewBox="0 0 454 329" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M46.5 -377L453.965 328.75H-360.965L46.5 -377Z" fill="#9879F0"/> </svg> </div> <div id="bg-8" class="bg-item" style="top: 15%; left: 0;"> <svg width="590" height="330" viewBox="0 0 590 330" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M-11 18L141 281H-163L-11 18Z" fill="#9879F0"/> <path d="M590 0H413V330H590V0Z" fill="#9879F0"/> </svg> </div> <div id="bg-9" class="bg-item" style="top: 32%; left: 36%;"> <svg width="174" height="237" viewBox="0 0 174 237" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M174 0H0V237H174V0Z" fill="#F56CF0"/> </svg> </div> <div id="bg-10" class="bg-item" style="top: 0; left: calc(50% - 182px);"> <svg width="364" height="234" viewBox="0 0 364 234" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M182 234C282.516 234 364 152.516 364 52C364 -48.5158 282.516 -130 182 -130C81.4842 -130 0 -48.5158 0 52C0 152.516 81.4842 234 182 234Z" fill="#7A8DF4"/> </svg> </div> <main class="calculator-wrapper"> <div class="title-wrapper"> <div class="title">Glassmorphism</div> <div class="title">Glassmorphism</div> </div> <section class="calculator"> <button id="toggler" class="toggle-theme"> <svg id="dark" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" style="display: block;"> <path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1.........完整代码请登录后点击上方下载按钮下载查看
网友评论0