A Pen by Bakaki Mahlon on CodePen.
Created
March 14, 2022 08:11
-
-
Save Git2020104/13002be18e5e59d40dbff5b9dd6cd6a9 to your computer and use it in GitHub Desktop.
Rubik's Input Concept - No JS!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="cell"> | |
<div class="cube-container"> | |
<label for="flip">Flip</label> | |
<input type="checkbox" id="flip"> | |
<div class="cube-wrapper"> | |
<div class="cube"> | |
<div class="face top"> | |
<div class="tile"> | |
<input name="1" type="radio"> | |
<input name="1" type="radio"> | |
<input name="1" type="radio"> | |
<input name="1" type="radio"> | |
<input name="1" type="radio"> | |
<input name="1" type="radio" checked> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="2" type="radio"> | |
<input name="2" type="radio"> | |
<input name="2" type="radio"> | |
<input name="2" type="radio"> | |
<input name="2" type="radio"> | |
<input name="2" type="radio" checked> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="3" type="radio"> | |
<input name="3" type="radio"> | |
<input name="3" type="radio"> | |
<input name="3" type="radio"> | |
<input name="3" type="radio"> | |
<input name="3" type="radio" checked> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="4" type="radio"> | |
<input name="4" type="radio"> | |
<input name="4" type="radio"> | |
<input name="4" type="radio"> | |
<input name="4" type="radio"> | |
<input name="4" type="radio" checked> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="5" type="radio"> | |
<input name="5" type="radio"> | |
<input name="5" type="radio"> | |
<input name="5" type="radio"> | |
<input name="5" type="radio"> | |
<input name="5" type="radio" checked> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="6" type="radio"> | |
<input name="6" type="radio"> | |
<input name="6" type="radio"> | |
<input name="6" type="radio"> | |
<input name="6" type="radio"> | |
<input name="6" type="radio" checked> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="7" type="radio"> | |
<input name="7" type="radio"> | |
<input name="7" type="radio"> | |
<input name="7" type="radio"> | |
<input name="7" type="radio"> | |
<input name="7" type="radio" checked> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="8" type="radio"> | |
<input name="8" type="radio"> | |
<input name="8" type="radio"> | |
<input name="8" type="radio"> | |
<input name="8" type="radio"> | |
<input name="8" type="radio" checked> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="9" type="radio"> | |
<input name="9" type="radio"> | |
<input name="9" type="radio"> | |
<input name="9" type="radio"> | |
<input name="9" type="radio"> | |
<input name="9" type="radio" checked> | |
<i></i> | |
</div> | |
</div> | |
<div class="face left"> | |
<div class="tile"> | |
<input name="10" type="radio"> | |
<input name="10" type="radio"> | |
<input name="10" type="radio"> | |
<input name="10" type="radio"> | |
<input name="10" type="radio" checked> | |
<input name="10" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="11" type="radio"> | |
<input name="11" type="radio"> | |
<input name="11" type="radio"> | |
<input name="11" type="radio"> | |
<input name="11" type="radio" checked> | |
<input name="11" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="12" type="radio"> | |
<input name="12" type="radio"> | |
<input name="12" type="radio"> | |
<input name="12" type="radio"> | |
<input name="12" type="radio" checked> | |
<input name="12" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="13" type="radio"> | |
<input name="13" type="radio"> | |
<input name="13" type="radio"> | |
<input name="13" type="radio"> | |
<input name="13" type="radio" checked> | |
<input name="13" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="14" type="radio"> | |
<input name="14" type="radio"> | |
<input name="14" type="radio"> | |
<input name="14" type="radio"> | |
<input name="14" type="radio" checked> | |
<input name="14" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="15" type="radio"> | |
<input name="15" type="radio"> | |
<input name="15" type="radio"> | |
<input name="15" type="radio"> | |
<input name="15" type="radio" checked> | |
<input name="15" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="16" type="radio"> | |
<input name="16" type="radio"> | |
<input name="16" type="radio"> | |
<input name="16" type="radio"> | |
<input name="16" type="radio" checked> | |
<input name="16" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="17" type="radio"> | |
<input name="17" type="radio"> | |
<input name="17" type="radio"> | |
<input name="17" type="radio"> | |
<input name="17" type="radio" checked> | |
<input name="17" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="18" type="radio"> | |
<input name="18" type="radio"> | |
<input name="18" type="radio"> | |
<input name="18" type="radio"> | |
<input name="18" type="radio" checked> | |
<input name="18" type="radio"> | |
<i></i> | |
</div> | |
</div> | |
<div class="face front"> | |
<div class="tile"> | |
<input name="19" type="radio"> | |
<input name="19" type="radio"> | |
<input name="19" type="radio"> | |
<input name="19" type="radio" checked> | |
<input name="19" type="radio"> | |
<input name="19" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="20" type="radio"> | |
<input name="20" type="radio"> | |
<input name="20" type="radio"> | |
<input name="20" type="radio" checked> | |
<input name="20" type="radio"> | |
<input name="20" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="21" type="radio"> | |
<input name="21" type="radio"> | |
<input name="21" type="radio"> | |
<input name="21" type="radio" checked> | |
<input name="21" type="radio"> | |
<input name="21" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="22" type="radio"> | |
<input name="22" type="radio"> | |
<input name="22" type="radio"> | |
<input name="22" type="radio" checked> | |
<input name="22" type="radio"> | |
<input name="22" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="23" type="radio"> | |
<input name="23" type="radio"> | |
<input name="23" type="radio"> | |
<input name="23" type="radio" checked> | |
<input name="23" type="radio"> | |
<input name="23" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="24" type="radio"> | |
<input name="24" type="radio"> | |
<input name="24" type="radio"> | |
<input name="24" type="radio" checked> | |
<input name="24" type="radio"> | |
<input name="24" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="25" type="radio"> | |
<input name="25" type="radio"> | |
<input name="25" type="radio"> | |
<input name="25" type="radio" checked> | |
<input name="25" type="radio"> | |
<input name="25" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="26" type="radio"> | |
<input name="26" type="radio"> | |
<input name="26" type="radio"> | |
<input name="26" type="radio" checked> | |
<input name="26" type="radio"> | |
<input name="26" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="27" type="radio"> | |
<input name="27" type="radio"> | |
<input name="27" type="radio"> | |
<input name="27" type="radio" checked> | |
<input name="27" type="radio"> | |
<input name="27" type="radio"> | |
<i></i> | |
</div> | |
</div> | |
<div class="face right"> | |
<div class="tile"> | |
<input name="28" type="radio"> | |
<input name="28" type="radio"> | |
<input name="28" type="radio" checked> | |
<input name="28" type="radio"> | |
<input name="28" type="radio"> | |
<input name="28" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="29" type="radio"> | |
<input name="29" type="radio"> | |
<input name="29" type="radio" checked> | |
<input name="29" type="radio"> | |
<input name="29" type="radio"> | |
<input name="29" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="30" type="radio"> | |
<input name="30" type="radio"> | |
<input name="30" type="radio" checked> | |
<input name="30" type="radio"> | |
<input name="30" type="radio"> | |
<input name="30" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="31" type="radio"> | |
<input name="31" type="radio"> | |
<input name="31" type="radio" checked> | |
<input name="31" type="radio"> | |
<input name="31" type="radio"> | |
<input name="31" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="32" type="radio"> | |
<input name="32" type="radio"> | |
<input name="32" type="radio" checked> | |
<input name="32" type="radio"> | |
<input name="32" type="radio"> | |
<input name="32" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="33" type="radio"> | |
<input name="33" type="radio"> | |
<input name="33" type="radio" checked> | |
<input name="33" type="radio"> | |
<input name="33" type="radio"> | |
<input name="33" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="34" type="radio"> | |
<input name="34" type="radio"> | |
<input name="34" type="radio" checked> | |
<input name="34" type="radio"> | |
<input name="34" type="radio"> | |
<input name="34" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="35" type="radio"> | |
<input name="35" type="radio"> | |
<input name="35" type="radio" checked> | |
<input name="35" type="radio"> | |
<input name="35" type="radio"> | |
<input name="35" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="36" type="radio"> | |
<input name="36" type="radio"> | |
<input name="36" type="radio" checked> | |
<input name="36" type="radio"> | |
<input name="36" type="radio"> | |
<input name="36" type="radio"> | |
<i></i> | |
</div> | |
</div> | |
<div class="face back"> | |
<div class="tile"> | |
<input name="37" type="radio"> | |
<input name="37" type="radio" checked> | |
<input name="37" type="radio"> | |
<input name="37" type="radio"> | |
<input name="37" type="radio"> | |
<input name="37" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="38" type="radio"> | |
<input name="38" type="radio" checked> | |
<input name="38" type="radio"> | |
<input name="38" type="radio"> | |
<input name="38" type="radio"> | |
<input name="38" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="39" type="radio"> | |
<input name="39" type="radio" checked> | |
<input name="39" type="radio"> | |
<input name="39" type="radio"> | |
<input name="39" type="radio"> | |
<input name="39" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="40" type="radio"> | |
<input name="40" type="radio" checked> | |
<input name="40" type="radio"> | |
<input name="40" type="radio"> | |
<input name="40" type="radio"> | |
<input name="40" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="41" type="radio"> | |
<input name="41" type="radio" checked> | |
<input name="41" type="radio"> | |
<input name="41" type="radio"> | |
<input name="41" type="radio"> | |
<input name="41" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="42" type="radio"> | |
<input name="42" type="radio" checked> | |
<input name="42" type="radio"> | |
<input name="42" type="radio"> | |
<input name="42" type="radio"> | |
<input name="42" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="43" type="radio"> | |
<input name="43" type="radio" checked> | |
<input name="43" type="radio"> | |
<input name="43" type="radio"> | |
<input name="43" type="radio"> | |
<input name="43" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="44" type="radio"> | |
<input name="44" type="radio" checked> | |
<input name="44" type="radio"> | |
<input name="44" type="radio"> | |
<input name="44" type="radio"> | |
<input name="44" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="45" type="radio"> | |
<input name="45" type="radio" checked> | |
<input name="45" type="radio"> | |
<input name="45" type="radio"> | |
<input name="45" type="radio"> | |
<input name="45" type="radio"> | |
<i></i> | |
</div> | |
</div> | |
<div class="face bottom"> | |
<div class="tile"> | |
<input name="46" type="radio" checked> | |
<input name="46" type="radio"> | |
<input name="46" type="radio"> | |
<input name="46" type="radio"> | |
<input name="46" type="radio"> | |
<input name="46" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="47" type="radio" checked> | |
<input name="47" type="radio"> | |
<input name="47" type="radio"> | |
<input name="47" type="radio"> | |
<input name="47" type="radio"> | |
<input name="47" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="48" type="radio" checked> | |
<input name="48" type="radio"> | |
<input name="48" type="radio"> | |
<input name="48" type="radio"> | |
<input name="48" type="radio"> | |
<input name="48" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="49" type="radio" checked> | |
<input name="49" type="radio"> | |
<input name="49" type="radio"> | |
<input name="49" type="radio"> | |
<input name="49" type="radio"> | |
<input name="49" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="50" type="radio" checked> | |
<input name="50" type="radio"> | |
<input name="50" type="radio"> | |
<input name="50" type="radio"> | |
<input name="50" type="radio"> | |
<input name="50" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="51" type="radio" checked> | |
<input name="51" type="radio"> | |
<input name="51" type="radio"> | |
<input name="51" type="radio"> | |
<input name="51" type="radio"> | |
<input name="51" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="52" type="radio" checked> | |
<input name="52" type="radio"> | |
<input name="52" type="radio"> | |
<input name="52" type="radio"> | |
<input name="52" type="radio"> | |
<input name="52" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="53" type="radio" checked> | |
<input name="53" type="radio"> | |
<input name="53" type="radio"> | |
<input name="53" type="radio"> | |
<input name="53" type="radio"> | |
<input name="53" type="radio"> | |
<i></i> | |
</div> | |
<div class="tile"> | |
<input name="54" type="radio" checked> | |
<input name="54" type="radio"> | |
<input name="54" type="radio"> | |
<input name="54" type="radio"> | |
<input name="54" type="radio"> | |
<input name="54" type="radio"> | |
<i></i> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No JavaScript!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
html, body { | |
width: 100%; | |
height: 100%; | |
} | |
body { | |
font-family: sans-serif; | |
background-color: hsl(0, 0%, 15%); | |
display: table; | |
} | |
.cell { | |
display: table-cell; | |
text-align: center; | |
vertical-align: middle; | |
} | |
.cube-container { | |
position: relative; | |
width: 400px; | |
height: 400px; | |
border-radius: 10px; | |
background-color: hsl(0, 0%, 85%); | |
padding: 100px; | |
margin: auto; | |
} | |
.cube-wrapper { | |
perspective: none; | |
perspective: 1500px; | |
perspective-origin: 50% 50%; | |
position: relative; | |
width: 200px; | |
height: 200px; | |
} | |
.cube { | |
position: relative; | |
width: 200px; | |
height: 200px; | |
transform-style: preserve-3d; | |
transition: transform 800ms; | |
transform: rotateX(-35deg) rotateY(45deg); | |
} | |
label { | |
display: block; | |
position: absolute; | |
top: 10px; | |
right: 10px; | |
padding: 8px 15px; | |
font-weight: bold; | |
border-radius: 5px; | |
font-size: 20px; | |
background-color: white; | |
color: black; | |
user-select: none; | |
} | |
label:active { | |
border: 2px solid black; | |
} | |
#flip { | |
display: none; | |
position: absolute; | |
} | |
#flip:checked + .cube-wrapper .cube { | |
transform: rotateX(145deg) rotateY(45deg); | |
} | |
.face { | |
display: flex; | |
flex-wrap: wrap; | |
width: 200px; | |
height: 200px; | |
justify-content: space-around; | |
align-items: center; | |
position: absolute; | |
background-color: hsla(0, 0%, 7.8%, 0.9); | |
backface-visibility: visible; | |
} | |
.face.left { | |
transform: rotateY(270deg) translateX(-50%); | |
transform-origin: center left; | |
} | |
.face.front { | |
transform: translateZ(100px); | |
} | |
.face.right { | |
transform: rotateY(-270deg) translateX(100px); | |
transform-origin: top right; | |
} | |
.face.back { | |
transform: translateZ(-100px) rotateY(180deg); | |
} | |
.face.top { | |
transform: rotateX(90deg) translateY(-100px); | |
transform-origin: top center; | |
} | |
.face.bottom { | |
transform: rotateX(-90deg) translateY(100px); | |
transform-origin: bottom center; | |
} | |
.tile { | |
position: relative; | |
overflow: hidden; | |
width: 30%; | |
height: 30%; | |
border-radius: 8px; | |
color: red; | |
text-shadow: 0 0 10px black; | |
font-size: 20px; | |
font-weight: bold; | |
user-select: none; | |
} | |
.tile i { | |
display: block; | |
position: absolute; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
pointer-events: none; | |
background-color: purple; | |
} | |
.tile i::after { | |
display: none; | |
content: ''; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
margin-top: -25%; | |
margin-left: -25%; | |
border-radius: 8px; | |
width: 50%; | |
height: 50%; | |
background-color: black; | |
pointer-events: none; | |
} | |
.tile:hover i::after { | |
display: block; | |
} | |
.tile input { | |
display: block; | |
position: absolute; | |
-webkit-appearance: none; | |
appearance: none; | |
background-color: transparent; | |
cursor: pointer; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
pointer-events: all; | |
outline: none; | |
} | |
.tile input:checked, | |
.tile input:checked ~ input { | |
pointer-events: none; | |
} | |
.tile input:nth-of-type(1):checked ~ input { | |
pointer-events: all; | |
} | |
.tile input:nth-of-type(1):checked ~ i { | |
background-color: hsl(50, 100%, 50%); | |
} | |
.tile input:nth-of-type(1):checked ~ i::after { | |
background-color: hsl(0, 0%, 100%); | |
} | |
.tile input:nth-of-type(2):checked ~ i { | |
background-color: hsl(148, 100%, 30.4%); | |
} | |
.tile input:nth-of-type(2):checked ~ i::after { | |
background-color: hsl(50, 100%, 50%); | |
} | |
.tile input:nth-of-type(3):checked ~ i { | |
background-color: hsl(21, 100%, 50%); | |
} | |
.tile input:nth-of-type(3):checked ~ i::after { | |
background-color: hsl(148, 100%, 30.4%); | |
} | |
.tile input:nth-of-type(4):checked ~ i { | |
background-color: hsl(216, 100%, 33.9%); | |
} | |
.tile input:nth-of-type(4):checked ~ i::after { | |
background-color: hsl(21, 100%, 50%); | |
} | |
.tile input:nth-of-type(5):checked ~ i { | |
background-color: hsl(348, 82.1%, 39.4%); | |
} | |
.tile input:nth-of-type(5):checked ~ i::after { | |
background-color: hsl(216, 100%, 33.9%); | |
} | |
.tile input:nth-of-type(6):checked ~ i { | |
background-color: hsl(0, 0%, 100%); | |
} | |
.tile input:nth-of-type(6):checked ~ i::after { | |
background-color: hsl(348, 82.1%, 39.4%); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment