div+css实现逼真可点击有音效的罗技键盘效果代码
代码语言:html
所属分类:布局界面
代码描述:div+css实现逼真可点击有音效的罗技键盘效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/reset.min.css"> <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@600&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" /> <style> :root { --key-text-highlight: #98ff00; } header, footer { display: flex; justify-content: center; align-items: center; flex-direction: column; gap: 0.75rem; color: #fff; } h1 { font-size: 2rem; } a { color: inherit; text-decoration: none; } a:hover { color: rgba(255, 255, 255, 0.75); } .material-symbols-outlined { pointer-events: none; } .small-text { font-size: 0.75rem; } .smaller-text { font-size: 0.625rem; } .color-white { color: #fff !important; } .main { box-sizing: border-box; display: grid; place-items: center; grid-template-rows: 5rem auto 3.75rem; padding: 1.5rem 0 2rem 0; width: 100vw; height: 100vh; font-family: "Outfit", sans-serif; background: #240054; background: linear-gradient(45deg, #240054 10%, #003098 100%); } .keyboard-wrapper { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; display: grid; grid-template-columns: repeat(4, auto); grid-template-rows: repeat(3, auto); gap: 0.625rem; padding: 0.625rem; border-radius: 0.25rem; border-left: 0.25rem solid #555560; border-right: 0.25rem solid #555560; background-color: #444450; } .keyboard-wrapper li { position: relative; top: 0; cursor: pointer; display: flex; justify-content: center; padding: 0.25rem 0; border-radius: 0.375rem; color: var(--key-text-highlight); font-size: 0.75rem; background: #141418; border-top: 0.125rem solid #202024; border-right: 0.25rem solid #202024; border-bottom: 0.375rem solid #242428; border-left: 0.25rem solid #202024; } .keyboard-wrapper li.caps-key.click, .keyboard-wrapper li.caps-key:hover { border-right: 0.8125rem solid #282832; } .keyboard-wrapper li.click, .keyboard-wrapper li:active { top: 0.0625rem; } .keyboard-wrapper li.click, .keyboard-wrapper li:hover { background: #202024; border-top: 0.125rem solid #282832; border-right: 0.25rem solid #282832; border-bottom: 0.375rem solid #323236; border-left: 0.25rem solid #282832; } .keyboard-wrapper li.click:after, .keyboard-wrapper li:hover:after { border-top: 0.125rem solid #282832 !important; border-bottom: 0.375rem solid #323236 !important; border-left: 0.25rem solid #282832 !important; } .keyboard-wrapper .logitech-logo { display: grid; place-content: center; grid-column-start: 1; font-size: 2.5rem; line-height: 1; color: #34edff; } .keyboard-wrapper .logitech-logo.active { -webkit-animation: rainbow 5s linear; animation: rainbow 5s linear; -webkit-animation-iteration-count: infinite; animation-iteration-count: infinite; } .keyboard-wrapper .utility-keys, .keyboard-wrapper .memory-keys { display: grid; place-items: center; grid-template-columns: repeat(4, 2.5rem); grid-column-start: 3; gap: 0.125rem; } .keyboard-wrapper .utility-keys li, .keyboard-wrapper .memory-keys li { color: #444; } .keyboard-wrapper .utility-keys li.active, .keyboard-wrapper .memory-keys li.active { color: var(--key-text-highlight); } .keyboard-wrapper .utility-keys { grid-template-columns: repeat(2, 2.5rem); grid-column-start: 4; } .keyboard-wrapper .utility-keys li { font-size: 1.125rem; } .keyboard-wrapper .utility-keys li.game span { font-size: 1rem; transform: rotate(-45deg) translateX(-0.0625rem) translateY(-0.0625rem); } .keyboard-wrapper .utility-keys li.brightness span { font-size: 1.125rem; margin-bottom: -0.0625rem; margin-right: -0.0625rem; } .keyboard-wrapper .info-lights { display: grid; grid-template-columns: repeat(2, 2.5rem); grid-column-start: 5; } .keyboard-wrapper .info-lights .info-light { cursor: auto; display: flex; justify-content: center; align-items: center; flex-direction: column; gap: 0.5rem; padding: 0; border: none; background: transparent; } .keyboard-wrapper .info-lights .info-light:hover:after { border-top: none !important; border-bottom: none !important; border-left: none !important; } .keyboard-wrapper .info-lights .info-light:after { content: ""; display: flex; width: 0.375rem; height: 0.375rem; border-radius: 10rem; background-color: #000; box-shadow: 0 0 0 #fff; } .keyboard-wrapper .info-lights .info-light span { color: #000; font-size: 0.375rem; text-align: center; } .keyboard-wrapper .info-lights .info-light.active:after { background-color: #fff; box-shadow: 0 0 0.25rem #fff; } .keyboard-wrapper .media-keys { display: grid; place-items: center; grid-template-columns: repeat(4, 2.5rem); grid-column-start: 4; grid-row-start: 2; gap: 0.125rem; } .keyboard-wrapper .media-keys li { font-size: 0.5rem; } .keyboard-wrapper .volume-wheel_box { position: relative; padding: 0 0.625rem 0.625rem 0.625rem; top: -0.625rem; background: #141418; border-left: 0.5rem solid #202024; border-right: 0.5rem solid #202024; border-bottom: 0.5rem solid #202024; border-bottom-left-radius: 1rem; border-bottom-right-radius: 1rem; } .keyboard-wrapper .volume-wheel_scroll { cursor: -webkit-grab; cursor: grab; background: #333; background: linear-gradient(0deg, #222222 0%, #222222 25%, #444444 50%, #333333 75%, #333333 100%); height: 1.8125rem; border: 0.0625rem solid #383838; border-radius: 0.25rem; } .keyboard-wrapper .round-key { box-sizing: border-box; display: grid; place-content: center; width: 2rem; height: 2rem; border-radius: 10rem; border: 0.1875rem solid #202024; } .keyboard-wrapper .round-key:hover { background: #202024; border: 0.125rem solid #282832; } .keyboard-wrapper .long-word-key { padding-top: 0.375rem; font-size: 0.5rem; } .keyboard-wrapper .backspace-key { font-size: 0.875rem; line-height: 0.3125rem; } .keyboard-wrapper .caps-key { border-right: 0.8125rem solid #202024; } .keyboard-wrapper .enter-key { display: grid; grid-column-start: 2; grid-column-end: 2; grid-row-start: 1; grid-row-end: span 2; } .keyboard-wrapper .enter-key li { position: relative; display: grid; place-items: center; border-top-left-radius: 0; } .keyboard-wrapper .enter-key li:after { content: ""; box-sizing: border-box; position: absolute; top: -0.09375rem; left: -0.875rem; width: 0.875rem; height: 2.5rem; border-top-left-radius: 0.375rem; border-bottom-left-radius: 0.375rem; border-top: 0.125rem solid #202024; border-bottom: 0.375rem solid #242428; border-left: 0.25rem solid #202024; background-color: inherit; } .keyboard-wrapper .enter-key li span { font-size: 1rem; } .keyboard-wrapper .windows-key { display: flex; justify-content: center; align-items: flex-start; } .keyboard-wrapper .windows-key_box { display: grid; grid-template-columns: 0.3125rem 0.3125rem; grid-template-rows: 0.25rem 0.25rem; gap: 0.0625rem; transform: perspective(0.625rem) rotate3D(0, 1, -0.1, -15deg); } .keyboard-wrapper .windows-key span { width: 0.3125rem; height: 0.25rem; background-color: var(--key-text-highlight); } .keyboard-wrapper .space-key { font-size: 0.875rem; line-height: 0; } .keyboard-wrapper .context-key { display: flex; justify-content: center; align-items: flex-start; } .keyboard-wrapper .context-key_box { display: grid; grid-template-columns: 0.25rem; grid-template-rows: 0.0625rem 0.0625rem 0.0625rem; gap: 0.0625rem; padding: 0.0625rem 0.125rem; border: 0.09375rem solid var(--key-text-highlight); } .keyboard-wrapper .context-key span { width: 0.25rem; height: 0.0625rem; background-color: var(--key-text-highlight); } .keyboard-wrapper .up-arrow-key { font-size: 0.875rem; grid-column-start: 2; grid-row-start: 4; } .keyboard-wrapper .left-arrow-key { font-size: 0.875rem; grid-column-start: 1; grid-row-start: 5; } .keyboard-wrapper .down-arrow-key { font-size: 0.875rem; grid-column-start: 2; grid-row-start: 5; } .keyboard-wrapper .right-arrow-key { font-size: 0.875rem; grid-column-start: 3; grid-row-start: 5; } .keyboard-wrapper .numpad-minus { font-size: 0.875rem; line-height: 0; } .keyboard-wrapper .numpad-plus { grid-column-start: 4; grid-row-start: 2; grid-row-end: span 2; padding-top: 1.25rem; font-size: 0.875rem; } .keyboard-wrapper .numpad-enter { grid-column-start: 4; grid-row-start: 4; grid-row-end: span 2; padding-top: 1.5625rem; } .keyboard-wrapper .numpad-zero { grid-column-start: 1; grid-column-end: span 2; } .keyboard-wrapper .numpad-dot { font-size: 1rem; line-height: 0; } .header-keys { display: grid; grid-template-columns: 2.5rem 5rem 12.125rem 14.875rem auto 10.5rem; grid-template-rows: 2.5rem; grid-column-start: 1; grid-column-end: span 4; grid-row-start: 1; } .f-keys { display: grid; grid-template-columns: 2.5rem 1.625rem repeat(4, 2.5rem) 1.5625rem repeat(4, 2.5rem) 1.5625rem repeat(4, 2.5rem); grid-template-rows: 2.5rem; grid-column-start: 2; grid-row-start: 2; gap: 0.125rem; } .f-keys li:nth-child(1) { grid-column-start: 1; } .f-keys .........完整代码请登录后点击上方下载按钮下载查看
网友评论0