<input id="mole-hole-toggle" class="toggle mole-hole-toggle" name="mole-whack" type="radio" />
<input id="mole-mole-toggle" class="toggle mole-mole-toggle" name="mole-whack" type="radio" />
<div class="mole-game">
<label class="mole-hole" for="mole-hole-toggle"></label>
<label class="mole-mole" for="mole-mole-toggle"></label>
</div>
<p class="mole-result mole-hole-result">Hole whacked!</p>
<p class="mole-result mole-mole-result">Mole whacked!</p>
.mole-game {
position: relative;
width: 13em;
height: 6em;
border: 0.125em solid #859fab;
overflow: hidden;
background-color: #546269;
color: #000;
text-align: center;
}
.mole-hole, .mole-mole {
display: block;
position: absolute;
top: 1.5em;
left: 1.5em;
cursor: crosshair;
}
.mole-hole {
width: 4.4em;
height: 2.7em;
border: 0.3em solid #30383b;
border-bottom-width: 0;
border-radius: 50%;
background-color: #22282a;
}
.mole-hole::before, .mole-hole::after, .mole-mole::before, .mole-mole::after,
.mole-mole:active::before, .mole-mole:active::after {
content: '';
display: block;
position: absolute;
border-radius: 0.5em;
transform: rotate(-30deg);
}
.mole-hole::before, .mole-mole:active::before {
top: -8em;
left: 4.5em;
width: 1em;
height: 4em;
background-color: #30383b;
transform-origin: bottom right;
}
.mole-hole::after, .mole-mole:active::after {
top: -8em;
left: 3em;
width: 4em;
height: 2em;
background-color: #444f55;
transform-origin: 2.5em 5.5em;
}
.mole-hole:active::before, .mole-hole:active::after,
.mole-mole:active::before, .mole-mole:active::after {
animation-name: hammer;
animation-duration: 200ms;
}
.mole-hole:active::before, .mole-mole:active::before {
top: -0.5em;
}
.mole-hole:active::after, .mole-mole:active::after {
top: -2em;
}
.mole-mole {
left: 16em;
width: 5em;
height: 3em;
animation-name: mole;
animation-duration: 10s;
animation-iteration-count: infinite;
animation-timing-function: step-end;
}
.mole-mole:active {
animation-play-state: paused;
}
.mole-mole::before, .mole-mole::after {
transform: none;
}
.mole-mole::before {
top: 0.25em;
left: 1.25em;
width: 2.5em;
height: 2.5em;
border-radius: 1em 1em 0.5em 0.5em;
background-color: #30383b;
}
.mole-mole::after {
content: '..';
top: 0.5em;
left: 1.75em;
width: 1.5em;
height: 1em;
border-radius: 0.5em;
background-color: #444f55;
font-weight: bold;
}
.mole-result {
display: none;
clear: left;
margin: 0 1em;
padding: 1em 0;
}
.mole-hole-toggle:checked ~ .mole-hole-result,
.mole-mole-toggle:checked ~ .mole-mole-result {
display: block;
}
body {
background-color: #161819;
color: #617078;
font: 20px/1.5 'Titillium Web', sans-serif;
}
.toggle {
display: none;
}
@keyframes hammer {
0% {
transform: rotate(-30deg);
}
50% {
transform: rotate(-45deg);
}
100% {
transform: rotate(-30deg);
}
}
@keyframes mole {
27.75% {
left: 1.5em;
}
33.50% {
left: 16em;
}
59.00% {
left: 1.5em;
}
65.00% {
left: 16em;
}
93.75% {
left: 1.5em;
}
97.50% {
left: 16em;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.