Pen Settings



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


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


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.


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.


                <div class="demo">
    <div id="droparea" class="droppable"></div>
    <div id="box"></div>  


    background-color: #f0f0f0;
    box-sizing: border-box;
    border: 1px solid #646464;
    padding: 10px;
    width: 100%;
    height: 300px;
    position: relative;

#droparea {
    background-color: #e6e6e6;
    box-sizing: border-box;
    border: 1px dotted #646464;
    width: 50%;
    height: 100%;

#box {
    cursor: grab;
    background-color: #000;
    width: 40px;
    height: 40px;
    position: absolute;
    top: 50%;
    left: 70%;


                let dropJudge = null;
const boxDOM = document.querySelector('#box');
const dropareaDOM = document.querySelector('#droparea');
boxDOM.onmousedown = function(event) { = 'grabbing';
   let shiftX = event.clientX - boxDOM.getBoundingClientRect().left;
   let shiftY = event.clientY - boxDOM.getBoundingClientRect().top; = 'absolute'; = 1000;
   movePosition(event.pageX, event.pageY);
   // #box要素の位置を決める
   function movePosition(pageX, pageY) { = pageX - shiftX + 'px'; = pageY - shiftY + 'px';
   // マウスを動かした時の処理
   function mouseMove(event) {
       movePosition(event.pageX, event.pageY);
       boxDOM.hidden = true;
       let elemBelow = document.elementFromPoint(event.clientX, event.clientY);
       boxDOM.hidden = false;
       let droppableBelow = elemBelow.closest('#droparea');
       if (dropJudge != droppableBelow) {
           if (dropJudge) {
           dropJudge = droppableBelow;
           if (dropJudge) {
   document.addEventListener('mousemove', mouseMove);
   // マウスを離した時にmousemoveイベントを解除する
   document.onmouseup = function() {
       document.removeEventListener('mousemove', mouseMove); = 'grab';
function onDroppable(element) { = '#969696';
function notDroppable(element) { = '#e6e6e6';
boxDOM.ondragstart = function() {
   return false;