Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main>
  <div class="egg egg1"><input type="checkbox" /></div>
  <div class="egg egg2"><input type="checkbox" /></div>
  <div class="egg egg3"><input type="checkbox" /></div>
  <div class="egg egg4"><input type="checkbox" /></div>
  <div class="egg egg5"><input type="checkbox" /></div>
  <div class="egg egg6"><input type="checkbox" /></div>
  <div class="egg egg7"><input type="checkbox" /></div>
  <div class="egg egg8"><input type="checkbox" /></div>
  <div class="egg egg9"><input type="checkbox" /></div>
  <div class="egg egg10"><input type="checkbox" /></div>
  <h1 class="title">
    Whacky Egg
    <p>Click as many eggs as you can before the timer runs out.</p>
  </h1>
  <input class="ready" type="checkbox" />
  <div class="countdown"></div>
  <a class="gameover">
    <h2>Game over</h2>
    <p class="score"></p>
  </a>
</main>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Titan+One&display=swap");

:root {
  --speed: 1;
  --gametime: 7.5s;
}

main {
  counter-reset: checked-sum;
}

body {
  margin: 0;
  overflow: none;
  display: grid;
  place-items: center;
  background-color: black;
}

main {
  position: relative;
  width: 800px;
  height: 100vh;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: 6fr 3fr 4fr 5fr;
  gap: 1px 1px;
  grid-template-areas: ". title title title title title title ." ". egg1 egg1 egg2 egg2 egg3 egg3 ." "egg4 egg4 egg5 egg5 egg6 egg6 egg7 egg7" ". egg8 egg8 egg9 egg9 egg10 egg10 .";
  align-items: center;
  justify-items: center;
  background-image: linear-gradient(#0000ff, #0000ff 33%, #00ff00 33%, #008800);
}

.egg1 {
  grid-area: egg1;
}
.egg2 {
  grid-area: egg2;
}
.egg3 {
  grid-area: egg3;
}
.egg4 {
  grid-area: egg4;
}
.egg5 {
  grid-area: egg5;
}
.egg6 {
  grid-area: egg6;
}
.egg7 {
  grid-area: egg7;
}
.egg8 {
  grid-area: egg8;
}
.egg9 {
  grid-area: egg9;
}
.egg10 {
  grid-area: egg10;
}

.title {
  text-align: center;
  grid-area: title;
  font-family: "Titan One", cursive;
  font-size: 80px;
  color: white;
}

.title > p {
  font-size: 24px;
  padding: 0 100px;
}

.score {
  font-family: "Titan One", cursive;
  font-size: 60px;
  color: white;
}

.score::after {
  content: "You scored " counter(checked-sum);
}

div.egg {
  position: relative;
  width: 100%;
  height: 40%;
  border-radius: 50%;
  background-color: black;
  -webkit-clip-path: polygon(
    0 -100px,
    100% -100px,
    100% 50%,
    87.5% 80%,
    75% 90%,
    62.5% 95%,
    50% 100%,
    37.5% 95%,
    25% 90%,
    12.5% 80%,
    0 50%
  );
  clip-path: polygon(
    0 -100px,
    100% -100px,
    100% 50%,
    87.5% 80%,
    75% 90%,
    62.5% 95%,
    50% 100%,
    37.5% 95%,
    25% 90%,
    12.5% 80%,
    0 50%
  );
  transform: scale(var(--scale));
}

div.egg > input[type="checkbox"] {
  position: absolute;
  appearance: none;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  opacity: 1;
  animation-name: timer;
  animation-duration: calc(2s / var(--speed));
  animation-iteration-count: infinite;
  animation-direction: alternate;
  animation-timing-function: ease-in;
  transform: translateY(200px);
  outline-width: 0;
}

div.egg > input[type="checkbox"]:before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  width: 80%;
  height: 100%;
  transform: scaleY(var(--egg));
  background-color: white;
  border-radius: 50%;
  opacity: 1;
}

div.egg > input[type="checkbox"]:checked {
  transform: translateY(0);
  pointer-events: none;
  animation-play-state: paused;
}

div.egg > input {
  animation-delay: calc(0.5s * var(--delay));
}

div.egg:nth-of-type(1) {
  --scale: 0.7;
  --delay: 1;
  --egg: 3;
}
div.egg:nth-of-type(2) {
  --scale: 0.7;
  --delay: 5;
  --egg: 3;
}
div.egg:nth-of-type(3) {
  --scale: 0.7;
  --delay: 8;
  --egg: 3;
}
div.egg:nth-of-type(4) {
  --scale: 0.85;
  --delay: 6;
  --egg: 2.6;
}
div.egg:nth-of-type(5) {
  --scale: 0.85;
  --delay: 9;
  --egg: 2.6;
}
div.egg:nth-of-type(6) {
  --scale: 0.85;
  --delay: 2;
  --egg: 2.6;
}
div.egg:nth-of-type(7) {
  --scale: 0.85;
  --delay: 10;
  --egg: 2.6;
}
div.egg:nth-of-type(8) {
  --scale: 1;
  --delay: 3;
  --egg: 2;
}
div.egg:nth-of-type(9) {
  --scale: 1;
  --delay: 7;
  --egg: 2;
}
div.egg:nth-of-type(10) {
  --scale: 1;
  --delay: 4;
  --egg: 2;
}

@keyframes timer {
  0% {
    transform: translateY(200px);
  }
  100% {
    transform: translateY(0px);
  }
}

div > input[type="checkbox"]:checked {
  counter-increment: checked-sum;
}

.ready {
  position: absolute;
  top: 33%;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  padding: 0;
  margin: 0;
  appearance: none;
}

.ready:after {
  content: "Click to start";
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  display: grid;
  place-items: center;
  font-family: "Titan One", cursive;
  font-size: 80px;
  color: white;
}

.ready:checked {
  pointer-events: none;
}

.ready:checked:after {
  display: none;
}

.countdown {
  pointer-events: none;
  position: absolute;
  top: 31.5%;
  left: 0;
  height: 2.5%;
  width: 100%;
  padding: 0;
  margin: 0;
  background-color: rgba(0, 255, 0, 0.75);
  animation-name: countdowntimer;
  animation-duration: var(--gametime);
  animation-iteration-count: 1;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
  animation-play-state: paused;
  transition-origin: top left;
}

.ready:checked ~ .countdown {
  animation-play-state: running;
}

@keyframes countdowntimer {
  0% {
    width: 100%;
  }
  100% {
    width: 0;
  }
}

.gameover {
  pointer-events: all;
  position: absolute;
  top: 33%;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  padding: 0;
  margin: 0;
  background-color: rgba(0, 0, 0, 0.85);
  display: grid;
  place-items: center;
  font-family: "Titan One", cursive;
  font-size: 80px;
  color: white;
  animation-name: gametimer;
  animation-duration: var(--gametime);
  animation-iteration-count: 1;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
  animation-play-state: paused;
  transform: translateX(-101vw);
}

.ready:checked ~ .gameover {
  animation-play-state: running;
}

@keyframes gametimer {
  0% {
    transform: translateX(-101vw);
  }
  99.9% {
    transform: translateX(-101vw);
  }
  100% {
    transform: translateX(0px);
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console