Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                
<div class="quiz-wrapper">
	<p class="question-description">Fill in the blanks by dragging the missing answer.</p>
	<ul class="options">
		<li class="title">Options</li>
		<li class="option" data-target="carraway">Nick Carraway</li>
		<li class="option" data-target="fitz">F. Scott Fitzgerald</li>
		<li class="option" data-target="westegg">West Egg</li>
		<li class="option" data-target="buchanan">Tom Buchanan</li>
		<li class="option" data-target="daisy">Daisy</li>
		<li class="option" data-target="ashes">Valley of Ashes</li>
	</ul>
<div class="answers">
	<ol>
		<li><span class="target" data-accept="fitz">&nbsp;</span>, a native of St Paul, Minnesota, and also a member of the "Lost Generation" finished four novels including "This Side of Paradise".</li>
		<li><span class="target" data-accept="carraway">&nbsp;</span> attended Yale with the large and brooding<span class="target" data-accept="buchanan">&nbsp;</span>.</li>
		<li>George Wilson owns an unsuccessful garage in an area known as the <span class="target" data-accept="ashes">&nbsp;</span>, where Tom brings Nick for a party.</li>
		<li>Jay Gatsby, the Buchanans, and Nick himself all make<span class="target" data-accept="westegg">&nbsp;</span>their home.</li>
	</ol>
</div>
 <button type="submit" value="submit">Submit</button>
 <div class="lightbox-bg"></div>
 <div class="status confirm">
   <p>All Answers Answered</p>
 </div>
 <div class="status deny">
   <p>Answers Remain</p>
 </div>
</div>
              
            
!

CSS

              
                .quiz-wrapper {
  position: relative;
  display: block;
  width: 510px;
  height: 450px;
  p.question-description {
    background: #19286C;
    color: white;
    padding: 25px 20px;
  }
  ul.options {
    position: relative;
    display: inline-block;
    vertical-align: top;
    width: 165px;
    list-style: none;
    border: 1px solid #19286C;
    text-align: center;
    padding: 0;
    margin: 0;
    li {
      border: 1px solid transparent;
      padding: 6px 8px;
    }
    li.title {
      background: #19286C;
      color: white;
    }
    li.option { 
      display: block;
      position: relative;
      z-index: 50;
      font-size: 13px;
    }
  }
  .answers {
    display: inline-block;
    width: 335px;
    font-size: 13px;
    line-height: 20px;
    .target {
     display: inline-block;
      width: 110px;
      background: lightblue;
      margin: 0 3px;
      text-align:center;
    }
  }
  button[type="submit"] {
    display:block;
    position: relative;
    margin:10px auto;
    padding: 10px;
    background: #19286C;
    border: none;
    color: white;
    font-size: 16px;
  }
}
.lightbox-bg {
  display: none;
  position: absolute;
  z-index: 100;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: rgba( 0,0,0,.7 );
}
.status {
  display: none;
  position: absolute;
  z-index: 110;
  text-align:center;
  width: 80%;
  top: 220px;
  left: 47px;
  p {
    background: white;
    padding: 30px;
  }
}
              
            
!

JS

              
                /**
* Drag and drop quiz intended for an iBooks widget
*/

$(document).ready( function() {
  //initialize the quiz options
  var answersLeft = [];
  $('.quiz-wrapper').find('li.option').each( function(i) {
    var $this = $(this);
    var answerValue = $this.data('target');
    var $target = $('.answers .target[data-accept="'+answerValue+'"]');
    var labelText = $this.html();
    $this.draggable( {
      revert: "invalid",
      containment: ".quiz-wrapper"
    });
   
    if ( $target.length > 0 ) {
    $target.droppable( {
        accept: 'li.option[data-target="'+answerValue+'"]',
        drop: function( event, ui ) {
          $this.draggable('destroy');
          $target.droppable('destroy');
          $this.html('&nbsp;');
          $target.html(labelText);
          answersLeft.splice( answersLeft.indexOf( answerValue ), 1 );
        }
    });
    answersLeft.push(answerValue);
    } else { }
   });
   $('.quiz-wrapper button[type="submit"]').click( function() {
	   if ( answersLeft.length > 0 ) {
		    $('.lightbox-bg').show();
      $('.status.deny').show();
      $('.lightbox-bg').click( function() {
		      $('.lightbox-bg').hide();
        $('.status.deny').hide();
        $('.lightbox-bg').unbind('click');
      });
	   } else {
		    $('.lightbox-bg').show();
      $('.status.confirm').show();
	   }
   });
});

              
            
!
999px

Console