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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <div class="holder">
  <h1>HTML5: Drag and Drop <span>{ Best on Google Chrome }</span></h1>
  <div id="bin">
<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAHmElEQVR4nO3dza9thxjH8bW56pbrrSRalMagVEsrgonRRRPXS0kHRkw7agxEIjFBSaRD8UfokNJEUAwYmFwUN9RrW22Jt7pafRHbs7JvI2mquWe/3Get9ft8kidrdM95zt57fc/a+5yz72oIsV6vL6nDB2pO1lxV8+qai2pe3LkXO/t7zWM199acqflWze2r1epvrVvNxKp7gUOrE/+NdfhkzY01z21ehwtjDMJtNZ+uEPy2e5kpW2wA6sQ/UYdba26qeVbzOvQYQzA+Bj5XIXi8e5kpWmQA6uS/og5fq7m6eRWm4XTNBysC93QvMjWLC0Cd/NfW4Y6aV3TvwqSMJ//7KgJ3dS8yJYsKQJ3840n/w5pXdu/CJN1f8/aKwH3di0zFYp4b18n/wjp8c3Dy8/+N3yC+Xo+Vi7sXmYrFBKB8tuYN3UsweW8aNj8VYljIU4Aq+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AwQQAggkABBMACCYAEEwAIJgAQDABgGACAMEEAIIJAAQTAAgmABBMACCYAEAwAYBgAgDBBACCCQAEEwAIJgAQTAAgmABAMAGAYAIAwQQAggkABBMACCYAEEwAIJgAQDABgGACAMEEAIIJAAQTAAgmABBMACCYAEAwAYBgAgDBBACCCQAEEwAIJgAQTAAgmABAMAGAYAIAwQQAggkABBMACCYAEEwAIJgAQDABgGACAMEEAIIJAAQTAAgmABBMACCYAEAwAYBgAgDBBACCCQAEEwAIJgAQTAAgmABAMAGAYAIAwQQAggkABBMACCYAEEwAIJgAQDABgGACAMEEAIIJAAQTAAgmABBMACCYAEAwAYBgAgDBBACCCQAEEwAIJgAQTAAgmABAMAGAYAIAwQQAggkABBMACCYAEEwAIJgAQDABgGACAMEEAIIJAAQ71r3A3K2Kz89cuQKAYAIAwQQAggkABBMACCYAEEwAIJgAQDABgGACAMEEAIIJAAQTAAgmABBMACDYFN4P4Ima52z7j9dlj7vAUTzWvcCupnAF8FD3ArCl2T92pxCA33QvAFv6dfcCu5pCAO7qXgC29JPuBXY1hQB8t3sB2NKd3Qvsqv0NHdfr9Yk6PFBzonsXOIKzNZeuVqtHuhfZRfsVQN2A/6zDl7v3gCO6be4n/6j9CmBUVwGvqsMvay7u3gXOw/ij66srAHd3L7Kr9iuAUd2Q99XhS917wHn64hJO/tEkrgBGdRVwvA4/qHlz9y7wDL5X8+4KwBPdi+zDZAIwqghcWYfv17ysexd4Gn+oeVud/Pd3L7Ivk3gK8KS6YcfXAa4fNjc0TMm9NaeWdPKPJhWAUd3Ap+twbc13uneBc75dc109Nmf/iz9PNbkAjOqG/ksdTtXcUjP7H7UwWw/XfKbmvfWY/Gv3MocwqdcAns56vb68Dp+v+XDNRc3rkGH8K7/xd1M+VSf+op+OTj4AT6oQvLQON9ScrHl9zRiG8cXCSV7FMBv/qfnzsHmOf2bYXO5/danf8Z/qv4kcmMGqxaKGAAAAAElFTkSuQmCC" />
  </div>
  <ul>
    <li><a draggable="true" href="" id="one">one</a></li>
    <li><a draggable="true" href="" id="two">two</a></li>
    <li><a draggable="true" href="" id="three">three</a></li>
    <li><a draggable="true" href="" id="four">four</a></li>
    <li><a draggable="true" href="" id="five">five</a></li>
  </ul>
</div>


              
            
!

CSS

              
                body{
  margin: 0px;
  padding: 0px;
  background: #e74c3c;
  font-family: 'Lato', sans-serif;
}

h1{
  color: #fff;
  text-align: center; 
  font-weight: 200;
  font-size: 80px;
}
h1 span{
  display: block;
  font-size: 40px;
}

.holder{
  width: 600px;
  margin: 0px auto;
}

li {
  list-style: none;
}

li a {
  text-decoration: none;
  color: #fff;
  margin: 10px;
  width: 150px;
  background: #eee;
  padding: 10px;
  display: block;
  text-align: center;
  font-size: 18px;
  cursor: move;
}

ul li:first-child a{ background: #34495e }
ul li:nth-child(2) a{ background: #3498db }
ul li:nth-child(3) a{ background: #f39c12 }
ul li:nth-child(4) a{ background: #27ae60 }
ul li:last-child a{ background: #9b59b6 }

*[draggable=true] {
  -moz-user-select:none;
  -khtml-user-drag: element;
  cursor: move;
}

*:-khtml-drag {
  background-color: rgba(238,238,238, 0.5);
}

li a:hover:after {
  content: ' (drag me)';
}

ul {
  margin-left: 200px;
  min-height: 300px;
}

li.over {
  border-color: #333;
  background: #ccc;
}

#bin {
  height: 250px;
  width: 166px;
  float: left;
  position: relative;
  margin-top: 0;
}

#bin.over {
  background: url(images/bin.jpg) top left no-repeat;
}

#bin p {
  font-weight: bold;
  text-align: center;
  position: absolute;
  bottom: 20px;
  width: 166px;
  font-size: 32px;
  color: #fff;
  top: -80px;
  left: 40px;
}

/*font-face*/
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 100;
  src: local('Lato Hairline'), local('Lato-Hairline'), url(http://themes.googleusercontent.com/static/fonts/lato/v6/boeCNmOCCh-EWFLSfVffDg.woff) format('woff');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 300;
  src: local('Lato Light'), local('Lato-Light'), url(http://themes.googleusercontent.com/static/fonts/lato/v6/KT3KS9Aol4WfR6Vas8kNcg.woff) format('woff');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  src: local('Lato Regular'), local('Lato-Regular'), url(http://themes.googleusercontent.com/static/fonts/lato/v6/9k-RPmcnxYEPm8CNFsH2gg.woff) format('woff');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 700;
  src: local('Lato Bold'), local('Lato-Bold'), url(http://themes.googleusercontent.com/static/fonts/lato/v6/wkfQbvfT_02e2IWO3yYueQ.woff) format('woff');
}

              
            
!

JS

              
                /*
* Credits to http://www.htmldrive.net/items/show/13/HTML5-Demo-drag-and-drop
*
*/

var addEvent = (function () {
  if (document.addEventListener) {
    return function (el, type, fn) {
      if (el && el.nodeName || el === window) {
        el.addEventListener(type, fn, false);
      } else if (el && el.length) {
        for (var i = 0; i < el.length; i++) {
          addEvent(el[i], type, fn);
        }
      }
    };
  } else {
    return function (el, type, fn) {
      if (el && el.nodeName || el === window) {
        el.attachEvent('on' + type, function () { return fn.call(el, window.event); });
      } else if (el && el.length) {
        for (var i = 0; i < el.length; i++) {
          addEvent(el[i], type, fn);
        }
      }
    };
  }
})();

(function () {

var pre = document.createElement('pre');
pre.id = "view-source"

// private scope to avoid conflicts with demos
addEvent(window, 'click', function (event) {
  if (event.target.hash == '#view-source') {
    // event.preventDefault();
    if (!document.getElementById('view-source')) {
      pre.innerHTML = ('<!DOCTYPE html>\n<html>\n' + document.documentElement.innerHTML + '\n</html>').replace(/[<>]/g, function (m) { return {'<':'&lt;','>':'&gt;'}[m]});
      document.body.appendChild(pre);      
    }
    document.body.className = 'view-source';
    
    var sourceTimer = setInterval(function () {
      if (window.location.hash != '#view-source') {
        clearInterval(sourceTimer);
        document.body.className = '';
      }
    }, 200);
  }
});
  
})();


  var eat = ['yum!', 'gulp', 'burp!', 'nom'];
  var yum = document.createElement('p');
  var msie = /*@cc_on!@*/0;
  yum.style.opacity = 1;

  var links = document.querySelectorAll('li > a'), el = null;
  for (var i = 0; i < links.length; i++) {
    el = links[i];
  
    el.setAttribute('draggable', 'true');
  
    addEvent(el, 'dragstart', function (e) {
      e.dataTransfer.effectAllowed = 'copy'; // only dropEffect='copy' will be dropable
      e.dataTransfer.setData('Text', this.id); // required otherwise doesn't work
    });
  }

  var bin = document.querySelector('#bin');

  addEvent(bin, 'dragover', function (e) {
    if (e.preventDefault) e.preventDefault(); // allows us to drop
    this.className = 'over';
    e.dataTransfer.dropEffect = 'copy';
    return false;
  });

  // to get IE to work
  addEvent(bin, 'dragenter', function (e) {
    this.className = 'over';
    return false;
  });

  addEvent(bin, 'dragleave', function () {
    this.className = '';
  });

  addEvent(bin, 'drop', function (e) {
    if (e.stopPropagation) e.stopPropagation(); // stops the browser from redirecting...why???

    var el = document.getElementById(e.dataTransfer.getData('Text'));
    
    el.parentNode.removeChild(el);

    // stupid nom text + fade effect
    bin.className = '';
    yum.innerHTML = eat[parseInt(Math.random() * eat.length)];

    var y = yum.cloneNode(true);
    bin.appendChild(y);

    setTimeout(function () {
      var t = setInterval(function () {
        if (y.style.opacity <= 0) {
          if (msie) { // don't bother with the animation
            y.style.display = 'none';
          }
          clearInterval(t); 
        } else {
          y.style.opacity -= 0.1;
        }
      }, 50);
    }, 250);

    return false;
  });


// For discussion and comments, see: https://remysharp.com/2009/01/07/html5-enabling-script/
/*@cc_on'abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video'.replace(/\w+/g,function(n){document.createElement(n)})@*/
              
            
!
999px

Console