css+div实现cps每秒点击次数测试比赛效果代码

代码语言:html

所属分类:其他

代码描述:css+div实现cps每秒点击次数测试比赛效果代码,疯狂点击鼠标左键,看你在10秒内能点击多少次,然后计算出cps值。

代码标签: css div cps 每秒 点击 次数 测试 比赛

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://fonts.googleapis.com/css2?family=Readex+Pro:wght@400;700&display=swap" rel="stylesheet">


  
  
<style>
:root {
  --space-0: 4px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-7: 56px;
  --space-8: 64px;
  --space-9: 72px;
  --space-10: 80px;
  --space-11: 88px;
  --space-12: 96px;
  --background: #f8fafb;
  --text-on-background: #000;
  --contrast: #282828;
  --text-on-contrast: #fff;
  --primary-color: #8cc152;
  --primary-color-alt: #a0d468;
  --cover-bg: #dba6a6;
  --text-on-primary: #fff;
}
h1,
h2,
h3,
p,
ul,
ol,
li,
* {
  margin: 0;
  padding: 0;
  font: inherit;
}
body {
  counter-reset: clicks;
  display: grid;
  place-items: stretch;
  min-height: 100dvh;
  background: var(--background);
  color: var(--text-on-background);
  font-family: 'Readex Pro', sans-serif;
  text-rendering: optimizeLegibility;
}
body main {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, auto) 1fr auto;
  grid-template-areas: "header header" "time clicks" "button button" "retry retry";
  grid-gap: var(--space-2);
  width: calc(100% - 2 * var(--space-2));
  margin: var(--space-2) auto;
  max-width: 800px;
}
@media all and (max-width: 420px) {
  body main {
    grid-template-columns: initial;
    grid-template-rows: repeat(3, auto) 1fr auto;
    grid-template-areas: "header" "time" "clicks" "button" "retry";
  }
}
body main h1 {
  grid-area: header;
  font-size: 3rem;
  text-align: center;
  font-weight: 700;
}
body main .time,
body main .clicks {
  background: var(--contrast);
  color: var(--text-on-contrast);
  padding: 1em;
  border-radius: var(--space-3);
  text-align: center;
  font-size: 1.5rem;
}
body main .time span,
body main .clicks span {
  margin-left: 0.5ch;
}
body main .time {
  grid-area: time;
}
body main .time .time_counter:before {
  content: '?';
  -webkit-animation: countdown 10s forwards paused;
          animation: countdown 10s forwards paused;
}
@-webkit-keyframes countdown {
  0% {
    content: '10s';
  }
  10% {
    content: '9s';
  }
  20% {
    content: '8s';
  }
  30% {
    content: '7s';
  }
  40% {
    content: '6s';
  }
  50% {
    content: '5s';
  }
  60% {
    content: '4s';
  }
  70% {
    content: '3s';
  }
  80% {
    content: '2s';
  }
  90% {
    content: '1s';
  }
  100% {
    content: '0s';
  }
}
@keyframes countdown {
  0% {
    content: '10s';
  }
  10% {
    content: '9s';
  }
  20% {
    content: '8s';
  }
  30% {
    content: '7s';
  }
  40% {
    content: '6s';
  }
  50% {
    content: '5s';
  }
  60% {
    content: '4s';
  }
  70% {
    content: '3s';
  }
  80% {
    content: '2s';
  }
  90% {
    content: '1s';
  }
  100% {
    content: '0s';
  }
}
body main .clicks {
  grid-area: clicks;
}
body main .clicks .clicks_counter:before {
  content: counter(clicks);
}
body main input[type="checkbox"],
body main .cover {
  place-items: center;
  grid-area: button;
  border-radius: var(--space-3);
}
body main input[type="checkbox"]:before,
body main .cover:before,
body main input[type="checkbox"]:after,
body main .cover:after {
  color: var(--text-on-primary);
  font-size: 2rem;
}
body main .cover {
  z-index: 1;
  position: relative;
  left: -10000vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 0 0 var(--space-1) var(--background);
  background: var(--cover-bg);
  -webkit-animation: ended 10s forwards steps(1) paused;
          animation: ended 10s forwards steps(1) paused;
}
body main .cover:before {
  content: "Time's Up";
}
body main .cover:after {
  content: "Rating: 🦥";
}
@-webkit-keyframes ended {
  99% {
    left: -10000vw;
  }
  100% {
    left: 0vw;
  }
}
@keyframes ended {
  99% {
    left: -10000vw;
  }
  100% {
    left: 0vw;
  }
}
body main input[type="checkbox"] {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  width: 100%;
  min-height: 300px;
  background: var(--primary-color);
  box-shadow: 0 0 0 var(--space-1) var(--background);
  transition: 0.1s -0.025s;
}
body main input[type="checkbox"]:first-of-type:before {
  content: 'Click to Start';
}
body main input[type="checkbox"]:hover {
  background: var(--primary-color-alt);
}
body main input[type="checkbox"]:not(:first-of-type) {
  display: none;
}
body main input[type="checkbox"]:checked {
  counter-increment: clicks;
}
body main input[type="checkbox"],
body main input[type="checkbox"]:checked+input {
  display: grid;
}
body main input[type="checkbox"]:before,
body main input[type="checkbox"]:checked+input:before {
  content: 'Keep Clicking';
}
body main input[type="checkbox"]:first-of-type:checked~.time .time_counter:before,
body main input[type="checkbox"]:first-of-type:checked~.cover {
  -webkit-animation-play-state: running;
          animation-play-state: running;
}
body main input[type="checkbox"]:nth-of-type(0):checked~.cover:before {
  content: '0 CPS';
}
body main input[type="checkbox"]:nth-of-type(1):checked~.cover:before {
  content: '0.1 CPS';
}
body main input[type="checkbox"]:nth-of-type(2):checked~.cover:before {
  content: '0.2 CPS';
}
body main input[type="checkbox"]:nth-of-type(3):checked~.cover:before {
  content: '0.3 CPS';
}
body main input[type="checkbox"]:nth-of-type(4):checked~.cover:before {
  content: '0.4 CPS';
}
body main input[type="checkbox"]:nth-of-type(5):checked~.cover:before {
  content: '0.5 CPS';
}
body main input[type="checkbox"]:nth-of-type(6):checked~.cover:before {
  content: '0.6 CPS';
}
body main input[type="checkbox"]:nth-of-type(7):checked~.cover:before {
  content: '0.7 CPS';
}
body main input[type="checkbox"]:nth-of-type(8):checked~.cover:before {
  content: '0.8 CPS';
}
body main input[type="checkbox"]:nth-of-type(9):checked~.cover:before {
  content: '0.9 CPS';
}
body main input[type="checkbox"]:nth-of-type(10):checked~.cover:before {
  content: '1 CPS';
}
body main input[type="checkbox"]:nth-of-type(11):checked~.cover:before {
  content: '1.1 CPS';
}
body main input[type="checkbox"]:nth-of-type(12):checked~.cover:before {
  content: '1.2 CPS';
}
body main input[type="checkbox"]:nth-of-type(13):checked~.cover:before {
  content: '1.3 CPS';
}
body main input[type="checkbox"]:nth-of-type(14):checked~.cover:before {
  content: '1.4 CPS';
}
body main input[type="checkbox"]:nth-of-type(15):checked~.cover:before {
  content: '1.5 CPS';
}
body main input[type="checkbox"]:nth-of-type(16):checked~.cover:before {
  content: '1.6 CPS';
}
body main input[type="checkbox"]:nth-of-type(17):checked~.cover:before {
  content: '1.7 CPS';
}
body main input[type="checkbox"]:nth-of-type(18):checked~.cover:before {
  content: '1.8 CPS';
}
body main input[type="checkbox"]:nth-of-type(19):checked~.cover:before {
  content: '1.9 CPS';
}
body main input[type="checkbox"]:nth-of-type(20):checked~.cover:before {
  content: '2 CPS';
}
body main input[type="checkbox"]:nth-of-type(21):checked~.cover:before {
  content: '2.1 CPS';
}
body main input[type="checkbox"]:nth-of-type(22):checked~.cover:before {
  content: '2.2 CPS';
}
body main input[type="checkbox"]:nth-of-type(23):checked~.cover:before {
  content: '2.3 CPS';
}
body main input[type="checkbox"]:nth-of-type(24):checked~.cover:before {
  content: '2.4 CPS';
}
body main input[type="checkbox"]:nth-of-type(25):checked~.cover:before {
  content: '2.5 CPS';
}
body main input[type="checkbox"]:nth-of-type(26):checked~.cover:before {
  content: '2.6 CPS';
}
body main input[type="checkbox"]:nth-of-type(27):checked~.cover:before {
  content: '2.7 CPS';
}
body main input[type="checkbox"]:nth-of-type(28):checked~.cover:before {
  content: '2.8 CPS';
}
body main input[type="checkbox"]:nth-of-type(29):checked~.cover:before {
  content: '2.9 CPS';
}
body main input[type=&quo.........完整代码请登录后点击上方下载按钮下载查看

网友评论0