div+css实现逼真可点击有音效的罗技键盘效果代码

代码语言:html

所属分类:布局界面

代码描述:div+css实现逼真可点击有音效的罗技键盘效果代码

代码标签: 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 li:nth-child(2) {
  grid-column-start: 3;
}
.f-keys li:nth-child(6) {
  grid-column-start: 8;
}
.f-keys li:nth-child(10) {
  grid-column-start: 13;
}

.g-keys {
  display: grid;
  grid-template-columns: 2.5rem;
  grid-template-rows: repeat(5, 2.5rem);
  grid-column-start: 1;
  grid-row-start: 3;
  gap: 0.125rem;
}

.center-keys {
  display: grid;
  grid-template-columns: auto;
  grid-template-rows: 2.5rem auto 2.5rem 2.5rem;
  grid-column-start: 2;
  grid-row-start: 3;
  gap: 0.125rem;
}
.center-keys_row-1 {
  display: grid;
  grid-template-columns: repeat(13, 2.5rem) 5rem;
  grid-template-rows: 2.5rem;
  grid-row-start: 1;
  gap: 0.125rem;
}
.center-keys_row-2-3 {
  display: grid;
  grid-template-columns: auto 3.125rem;
  grid-template-rows: 2.5rem 2.5rem;
  grid-row-start: 2;
  gap: 0.125rem;
}
.center-keys_row-2 {
  display: grid;
  grid-template-columns: 3.75rem repeat(12, 2.5rem);
  grid-template-rows: 2.5rem;
  grid-row-start: 1;
  gap: 0.125rem;
}
.center-keys_row-3 {
  display: grid;
  grid-template-columns: 4.375rem repeat(12, 2.5rem);
  grid-template-rows: 2.5rem;
  grid-row-start: 2;
  gap: 0.125rem;
}
.center-keys_row-4 {
  display: grid;
  grid-template-columns: 5.75rem repeat(10, 2.5rem) 7rem;
  grid-template-rows: 2.5rem;
  grid-row-start: 3;
  gap: 0.125rem;
}
.center-keys_row-5 {
  display: grid;
  grid-template-columns: 3.75rem repeat(2, 3.125rem) 15.125rem repeat(3, 3.125rem) 3.75rem;
  grid-template-rows: 2.5rem;
  grid-row-start: 4;
  gap: 0.125rem;
}

.print-scroll-pause-keys {
  display: grid;
  grid-template-columns: repeat(3, 2.5rem);
  grid-template-rows: 2.5rem;
  grid-column-start: 3;
  grid-row-start: 2;
  gap: 0.125rem;
}

.home-end-arrow-keys {
  display: grid;
  grid-template-columns: repeat(3, 2.5rem);
  grid-template-rows: repeat(5, 2.5rem);
  grid-column-start: 3;
  grid-row-start: 3;
  gap: 0.125rem;
}

.numpad-keys {
  display: grid;
  grid-template-columns: repeat(4, 2.5rem);
  grid-template-rows: repeat(5, 2.5rem);
  grid-column-start: 4;
  grid-row-start: 3;
  gap: 0.125rem;
}

@-webkit-keyframes rainbow {
  100%, 0% {
    color: #34edff;
  }
  10% {
    color: #00ff98;
  }
  20% {
    color: #98ff00;
  }
  30% {
    color: #ffe500;
  }
  40% {
    color: #ff8100;
  }
  50% {
    color: #ff0000;
  }
  60% {
    color: #ff0079;
  }
  70% {
    color: #c900ff;
  }
  80% {
    color: #7700ff;
  }
  90% {
    color: #0045ff;
  }
}

@keyframes rainbow {
  100%, 0% {
    color: #34edff;
  }
  10% {
    color: #00ff98;
  }
  20% {
    color: #98ff00;
  }
  30% {
    color: #ffe500;
  }
  40% {
    color: #ff8100;
  }
  50% {
    color: #ff0000;
  }
  60% {
    color: #ff0079;
  }
  70% {
    color: #c900ff;
  }
  80% {
    color: #7700ff;
  }
  90% {
    color: #0045ff;
  }
}
@media screen and (max-width: 1280px) {
  :root {
    font-size: 14px;
  }

  .keyboard-wrapper .enter-key li:after {
    top: calc(-0.09375rem - 0.2px);
  }
}
@media screen and (max-width: 1000px) {
  :root {
    font-size: 12px;
  }

  .keyboard-wrapper .enter-key li:after {
    top: -0.0625rem;
  }
}
</style>


  
</head>

<body >
  <div class="main">
	<header>
		<h1>Logitech G815</h1>
		<div class="small-text">MY DAILY WORK ❤</div>
	</header>
	<main class="keyboard-wrapper">
		<div class="header-keys">
			<div class="logitech-logo"><svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" viewBox="0 0 118 118"><g fill="currentColor"><path d="M19.08 18.97C29.93 7.54 45.55.9 61.31.95c0 8.03.01 16.07 0 24.1-10.65.1-21.21 5.22-27.43 13.94-7.85 10.55-8.65 25.73-1.93 37.04 5.83 10.4 17.51 16.86 29.36 16.92.01 8.03.01 16.07 0 24.1-13.89.01-27.7-5.07-38.18-14.19C10.75 92.29 3.14 76.31 2.99 60 2.63 44.9 8.6 29.83 19.08 18.97zM62.06 48.56H114c0 17.36.01 34.72-.01 52.07-7.97-.01-15.95-.01-23.92 0-.02-9.35 0-18.71-.01-28.06-9.33-.01-18.66-.01-27.99 0-.02-8-.01-16.01-.01-24.01z"/></g></svg></div>
			<ul class="memory-keys">
				<li class="round-key active">M1</li>
				<li class="round-key">M2</li>
				<li class="round-key">M3</li>
				<li class="round-key memory">MR</li>
			</ul>
			<ul class="utility-keys">
				<li class="round-key game"><span class="material-symbols-outlined">
						edit_square
					</span></li>
				<li class="round-key brightness active"><span class="material-symbols-outlined">light_mode</span></li>
			</ul>
			<ul class=&q.........完整代码请登录后点击上方下载按钮下载查看

网友评论0