<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<div class="dimensions x-axis">
<div class="space">
<div class="face">
<span class="front">Front</span>
<span class="back">Back</span>
</div>
</div>
<div class="space perspective">
<span class="arrow-container">
<span class="arrow-body"></span>
</span>
<div class="face">
<span class="front">Front</span>
<span class="back">Back</span>
</div>
</div>
<div class="space perspective flip">
<span class="arrow-container">
<span class="arrow-body"></span>
</span>
<div class="face">
<span class="front">Front</span>
<span class="back">Back</span>
</div>
</div>
</div>
<div class="dimensions y-axis">
<div class="space">
<div class="face">
<span class="front">Front</span>
<span class="back">Back</span>
</div>
</div>
<div class="space perspective">
<span class="arrow-container">
<span class="arrow-body"></span>
</span>
<div class="face">
<span class="front">Front</span>
<span class="back">Back</span>
</div>
</div>
<div class="space perspective flip">
<span class="arrow-container">
<span class="arrow-body"></span>
</span>
<div class="face">
<span class="front">Front</span>
<span class="back">Back</span>
</div>
</div>
</div>
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap');
:root {
--width: 20px;
}
* {
font-size:10px;
font-family: 'Fredoka One', cursive;
letter-spacing: .3em;
}
body {
height: 100vh;
align-items: center;
}
.dimensions {
width: 100%;
display: flex;
justify-content: center;
margin: 3rem 0;
}
@keyframes arrow-x {
from {
transform: translate(-50%, -30%) rotate(-30deg);
}
to {
transform: translate(-50%, -30%) rotate(1turn);
}
}
.arrow-container {
position:absolute;
width: var(--width);
height: var(--width);
z-index:1;
}
.x-axis .arrow-container {
top:50%;
left: 0%;
transform: translate(-50%, -30%) rotateY(-40deg);
}
.y-axis .arrow-container {
top:0;
left: 50%;
transform: translate(-30%, -110%) rotateX(-70deg) rotateZ(270deg);
}
.arrow-body {
position: absolute;
width: var(--width);
height: var(--width);
border: calc(var(--width) / 5) solid rgba(255, 0, 0, 1);
border-radius: 50%;
border-right-color: transparent;
animation: arrow-x 3s 1 forwards;
transition: transform;
}
.arrow-body::after {
content: "";
position: absolute;
top: -22.5%;
left: 65%;
border: calc(var(--width) * 0.5) solid transparent;
border-bottom-color: red;
border-top-width: 0;
border-right-width:0;
}
.space:hover .arrow-body {
animation: arrow-x 2s infinite;
}
.space {
width: 15rem;
height: 25rem;
border: 2px dashed #000;
margin: 0 3rem;
position: relative;
}
.space::after {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
.x-axis .space::after {
width: 125%;
height:2px;
border-top: 2px dashed rgba(0,0,0, 0.8);
}
.y-axis .space::after {
width: 2px;
height:115%;
border-right: 2px dashed rgba(0,0,0, 0.8);
}
.face {
width: 100%;
height: 100%;
background-color: rgba(204,204,204,.5);
position: relative;
z-index: 10;
}
.face > span {
position: absolute;
display: block;
font-size: 2rem;
text-transform: uppercase;
font-weight: bold;
}
.face .front {
top: 1rem;
left: 1rem;
color: rgba(80,22,116, 0.8);
}
.face .back {
bottom: 1rem;
right: 1rem;
color: rgba(22,42,116, 0.8);
}
.perspective {
perspective: 60rem;
}
.x-axis .perspective > div {
transform: rotateX(60deg);
}
.x-axis .flip > div {
transform: rotateX(140deg);
}
.y-axis .perspective > div {
transform: rotateY(60deg);
}
.y-axis .flip > div {
transform: rotateY(140deg);
}
.flip span:not(.arrow-body):not(.arrow-container) {
opacity: .6
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.