Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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.

+ add another resource

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div class="rb-box">

  <!-- Radio Button Module -->
  <p>1. On a scale of 1 to 5 how cubic are you?</p>
  <div id="rb-1" class="rb">
    <div class="rb-tab rb-tab-active" data-value="1">
      <div class="rb-spot">
        <span class="rb-txt">1</span>
      </div>
    </div><div class="rb-tab" data-value="2">
      <div class="rb-spot">
        <span class="rb-txt">2</span>
      </div>
    </div><div class="rb-tab" data-value="3">
      <div class="rb-spot">
        <span class="rb-txt">3</span>
      </div>
    </div><div class="rb-tab" data-value="4">
      <div class="rb-spot">
        <span class="rb-txt">4</span>
      </div>
    </div><div class="rb-tab" data-value="5">
      <div class="rb-spot">
        <span class="rb-txt">5</span>
      </div>
    </div>
  </div>

  <!-- Radio Button Module -->
  <p>2. On a scale of 1 to 5 how would you rate the universe?</p>
  <div id="rb-2" class="rb">
    <div class="rb-tab" data-value="1">
      <div class="rb-spot">
        <span class="rb-txt">1</span>
      </div>
    </div><div class="rb-tab rb-tab-active" data-value="2">
      <div class="rb-spot">
        <span class="rb-txt">2</span>
      </div>
    </div><div class="rb-tab" data-value="3">
      <div class="rb-spot">
        <span class="rb-txt">3</span>
      </div>
    </div><div class="rb-tab" data-value="4">
      <div class="rb-spot">
        <span class="rb-txt">4</span>
      </div>
    </div><div class="rb-tab" data-value="5">
      <div class="rb-spot">
        <span class="rb-txt">5</span>
      </div>
    </div>
  </div>

  <!-- Radio Button Module -->
  <p>3. On a scale of 1 to 5 how much do you like stalactites?</p>
  <div id="rb-3" class="rb">
    <div class="rb-tab" data-value="1">
      <div class="rb-spot">
        <span class="rb-txt">1</span>
      </div>
    </div><div class="rb-tab" data-value="2">
      <div class="rb-spot">
        <span class="rb-txt">2</span>
      </div>
    </div><div class="rb-tab rb-tab-active" data-value="3">
      <div class="rb-spot">
        <span class="rb-txt">3</span>
      </div>
    </div><div class="rb-tab" data-value="4">
      <div class="rb-spot">
        <span class="rb-txt">4</span>
      </div>
    </div><div class="rb-tab" data-value="5">
      <div class="rb-spot">
        <span class="rb-txt">5</span>
      </div>
    </div>
  </div>

  <!-- Radio Button Module -->
  <p>4. On a scale of 1 to 5 what is your favorite color in the alphabet?</p>
  <div id="rb-4" class="rb">
    <div class="rb-tab" data-value="1">
      <div class="rb-spot">
        <span class="rb-txt">1</span>
      </div>
    </div><div class="rb-tab" data-value="2">
      <div class="rb-spot">
        <span class="rb-txt">2</span>
      </div>
    </div><div class="rb-tab" data-value="3">
      <div class="rb-spot">
        <span class="rb-txt">3</span>
      </div>
    </div><div class="rb-tab rb-tab-active" data-value="4">
      <div class="rb-spot">
        <span class="rb-txt">4</span>
      </div>
    </div><div class="rb-tab" data-value="5">
      <div class="rb-spot">
        <span class="rb-txt">5</span>
      </div>
    </div>
  </div>

  <!-- Radio Button Module -->
  <p>5. On a scale of one to shrimp, how random are you?</p>
  <div id="rb-5" class="rb">
    <div class="rb-tab" data-value="4">
      <div class="rb-spot">
        <span class="rb-txt">4</span>
      </div>
    </div><div class="rb-tab" data-value="2">
      <div class="rb-spot">
        <span class="rb-txt">2</span>
      </div>
    </div><div class="rb-tab" data-value="5">
      <div class="rb-spot">
        <span class="rb-txt">5</span>
      </div>
    </div><div class="rb-tab" data-value="1">
      <div class="rb-spot">
        <span class="rb-txt">1</span>
      </div>
    </div><div class="rb-tab rb-tab-active" data-value="3">
      <div class="rb-spot">
        <span class="rb-txt">3</span>
      </div>
    </div>
  </div>

  <!-- Button -->
  <div class="button-box">
    <button class="button trigger">Submit!</button>
  </div>

</div>
              
            
!

CSS

              
                /* Containers */
html, body {
  min-height: 100%;
}

body {
  font-family: sans-serif;
  background: #42426b;
  background-image: -webkit-linear-gradient(135deg, #8067B7, #EC87C0);
  background-image: linear-gradient(-45deg, #8067B7, #EC87C0);
  color: rgba(255,255,255,.5);
}

.rb-box {
  width: 80%;
  max-width: 420px;
  margin: 50px auto;
  padding: 1.3em;
  background: #292942;
  border-radius: .75em;
  -webkit-filter: drop-shadow(1px 2px 5px rgba(0,0,0,.3));
  filter: drop-shadow(1px 2px 5px rgba(0,0,0,.3));
  box-shadow: 
    0 2px 2px rgba(243,49,128,.5),
    0 0px 5px rgba(243,49,128,.15),
    0 0px 4px rgba(0,0,0,.35),
    0 5px 20px rgba(243,49,128,.25),
    0 15px 50px rgba(243,49,128,.75),
    inset 0 0 15px rgba(255,255,255,.05);
}

/* Custom Radio Button */
p {
  font-size: .9em;
}

.rb {
  padding: 16px 0;
  text-align: center;
  background: rgba(255,255,255,.03);
  border-radius: .3em;
}

.rb-tab {
  display: inline-block;
  position: relative;
  width: 20%;
}

.rb-txt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: .5em;
  color: #FFFFFF;
}

.rb-spot {
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 100%;
  cursor: pointer;
  transition: ease .5s;
}

.rb-tab-active .rb-spot {
  background: rgba(0,0,0,.35);
  border: 2px solid rgba(243,49,128,.6);
}

/* Submit Button */
.button-box {
  padding: 10px 0;
  text-align: center;
}

button {
  display: inline-block;
  width: 80%;
  margin-top: 1.2em;
  padding: 1em;
  max-width: 220px;
  font-size: .9em;
  color: #D42D78;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: .15em;
  background: white;
  border: none;
  outline: none;
  border-radius: 5em;
  box-shadow: 0 15px 20px -10px rgba(0, 0, 0, 0.3);
  transition: 
    color 0.6s, 
    box-shadow 0.3s, 
    transform 0.3s;
  cursor: pointer;
}

button:hover {
  box-shadow: 0 3px 5px -5px rgba(0, 0, 0, 0.3);
  color: #6f6f6f;
}
              
            
!

JS

              
                /*
===============================================================

Hi! Welcome to my little playground!

My name is Tobias Bogliolo. 'Open source' by default and always 'responsive',
I'm a publicist, visual designer and frontend developer based in Barcelona. 

Here you will find some of my personal experiments. Sometimes usefull,
sometimes simply for fun. You are free to use them for whatever you want 
but I would appreciate an attribution from my work. I hope you enjoy it.

===============================================================
*/
//Global:
var survey = []; //Bidimensional array: [ [1,3], [2,4] ]

//Switcher function:
$(".rb-tab").click(function(){
  //Spot switcher:
  $(this).parent().find(".rb-tab").removeClass("rb-tab-active");
  $(this).addClass("rb-tab-active");
});

//Save data:
$(".trigger").click(function(){
  //Empty array:
  survey = [];
  //Push data:
  for (i=1; i<=$(".rb").length; i++) {
    var rb = "rb" + i;
    var rbValue = parseInt($("#rb-"+i).find(".rb-tab-active").attr("data-value"));
    //Bidimensional array push:
    survey.push([i, rbValue]); //Bidimensional array: [ [1,3], [2,4] ]
  };
  //Debug:
  debug();
});

//Debug:
function debug(){
  var debug = "";
  for (i=0; i<survey.length; i++) {
    debug += "Nº " + survey[i][0] + " = " + survey[i][1] + "\n";
  };
  alert(debug);
};
              
            
!
999px

Console