Not recommended for production use. But it seemed like a fun idea to see how far I could take a form with radio inputs.
A Pen by David Lewis on CodePen.
Not recommended for production use. But it seemed like a fun idea to see how far I could take a form with radio inputs.
A Pen by David Lewis on CodePen.
| <form> | |
| <input type="radio" name="fancy" autofocus value="clubs" id="clubs" /> | |
| <input type="radio" name="fancy" value="hearts" id="hearts" /> | |
| <input type="radio" name="fancy" value="spades" id="spades" /> | |
| <input type="radio" name="fancy" value="diamonds" id="diamonds" /> | |
| <label for="clubs">♣ Clubs</label><label for="hearts">♥ Hearts</label><label for="spades">♠ Spades</label><label for="diamonds">♦ Diamonds</label> | |
| <div class="keys">Use left and right keys to navigate</div> | |
| </form> |
| /* Nope */ |
| * { | |
| box-sizing: border-box; | |
| } | |
| body { | |
| font-family: sans-serif; | |
| overflow: hidden; | |
| } | |
| label { | |
| background: #444; | |
| color: #fff; | |
| transition: transform 400ms ease-out; | |
| display: inline-block; | |
| min-height: 100%; | |
| width: 100vw; | |
| height: 100vh; | |
| position: relative; | |
| z-index: 1; | |
| text-align: center; | |
| line-height: 100vh; | |
| } | |
| form { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| bottom: 0; | |
| right: 0; | |
| white-space: nowrap; | |
| } | |
| input { | |
| position: absolute; | |
| } | |
| .keys { | |
| position: fixed; | |
| z-index: 10; | |
| bottom: 0; | |
| left: 0; | |
| right: 0; | |
| padding: 1rem; | |
| color: #fff; | |
| text-align: center; | |
| transition: all 300ms linear; | |
| opacity: 0; | |
| } | |
| input:focus ~ .keys { | |
| opacity: 0.8; | |
| } | |
| input:nth-of-type(1):checked ~ label:nth-of-type(1), | |
| input:nth-of-type(2):checked ~ label:nth-of-type(2), | |
| input:nth-of-type(3):checked ~ label:nth-of-type(3), | |
| input:nth-of-type(4):checked ~ label:nth-of-type(4){ | |
| z-index: 0; | |
| } | |
| input:nth-of-type(1):checked ~ label { | |
| transform: translate3d(0, 0, 0); | |
| } | |
| input:nth-of-type(2):checked ~ label { | |
| transform: translate3d(-100%, 0, 0); | |
| } | |
| input:nth-of-type(3):checked ~ label { | |
| transform: translate3d(-200%, 0, 0); | |
| } | |
| input:nth-of-type(4):checked ~ label { | |
| transform: translate3d(-300%, 0, 0); | |
| } | |
| label { | |
| background: #444; | |
| background-size: cover; | |
| font-size: 3rem; | |
| } | |
| label[for="diamonds"], | |
| label[for="hearts"] { | |
| background: #cc0000; | |
| } | |
| label:before, | |
| label:after { | |
| color: white; | |
| display: block; | |
| background: rgba(255,255,255,0.2); | |
| position: absolute; | |
| padding: 1rem; | |
| font-size: 3rem; | |
| height: 10rem; | |
| vertical-align: middle; | |
| line-height: 10rem; | |
| top: 50%; | |
| transform: translate3d(0, -50%, 0); | |
| cursor: pointer; | |
| } | |
| label:before { | |
| content: "\276D"; | |
| right: 100%; | |
| border-top-left-radius: 50%; | |
| border-bottom-left-radius: 50%; | |
| } | |
| label:after { | |
| content: "\276C"; | |
| left: 100%; | |
| border-top-right-radius: 50%; | |
| border-bottom-right-radius: 50%; | |
| } | |