cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation


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.

              <section class="wrapper">
    <h2>Guess A Number</h2>
    <p>Using Sass-y magic, the computer "knows" a random number between 1 and 5.</p>
    <p>See if you can guess the right one (there will be a party when you do).</p>
      <label for="number1" tabindex="0">
      <input type="radio" name="number" id="number1" value="1"/>
      <label for="number2" tabindex="0">
      <input type="radio" name="number" id="number2" value="2"/>
      <label for="number3" tabindex="0">
      <input type="radio" name="number" id="number3" value="3"/>
      <label for="number4" tabindex="0">
      <input type="radio" name="number" id="number4" value="4"/>
      <label for="number5" tabindex="0">
      <input type="radio" name="number" id="number5" value="5"/>
              //set random number
$random-number: random(5);

//mixin for if/else
@mixin game-logic ($number) {
  @if round($random-number) == $number {
    animation: party-colors 2s infinite;
    background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/229892/ice-cream-parrot.gif);
    background-repeat: no-repeat;
    background-size: cover;
    transition: background-color 1s ease;
  @else {
    background-color: grey;
    transition: background-color 1s ease;

//include mixin for use
@each $number in 1, 2, 3, 4, 5 {
  #number#{$number}:checked + span::before {
    @include game-logic($number);

//keyframe for party-color animation
@keyframes party-colors {
  0% {background-color: teal;}
  25% {background-color: hotpink;}
  50% {background-color: dodgerblue;}
  75% {background-color: gold;}
  100% {background-color: teal;}

//The following three steps style the radio buttons
//This tutorial was my reference in that process: https://www.sitepoint.com/replacing-radio-buttons-without-replacing-radio-buttons/

//"hide" radio, still keeping it accessible
//from HTML5 Boilerplate
input[type="radio"] {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;

//center number below "radio" button
input[type="radio"] + span {
  display: inline-block;
  text-align: center;
  width: 5.3rem;

//styles new clickable "radio" area
//uses the + adjacent sibling selector and the ::before pseudo element to style the click area
input[type="radio"] + span::before {
  border: 0.125em solid #346699;
  content: '';
  display: inline-block;
  height: 5rem;
  width: 5rem;

//general styles
body {
  color: #346699;
  font-family: Helvetica, sans-serif;
  line-height: 1.4;

.wrapper {
  margin: 2rem auto;
  max-width: 40rem;
  width: 95%;

h2 {
  font-size: 1.5rem;
  font-weight: bold;

div {
  margin-bottom: 2rem;

label {
  margin-right: 1rem;
  &:last-of-type {
    margin-right: 0;

//removes default focus styling
label:focus {
  outline: none;

//adds custom focus state
label:focus input[type="radio"] + span {
  border: 2px dashed black;
  transition: border .3s ease;

//add border so that focus state doesn't jump
input[type="radio"] + span {
  border: 2px dashed transparent;
  transition: border .3s ease;
Loading ..................