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="container">
     <div class="col col-3">
       <div class="comp-holder">
         <div data-table="comp-01" class="comp js-draggable" draggable='true' ondragstart='onDragStart(event);' ondragend="onDragEnd(event);">
           [Header component]
         </div>
         <div data-table="comp-02" class="comp js-draggable" draggable='true' ondragstart='onDragStart(event);' ondragend="onDragEnd(event);">
           [Image component]
         </div>
         <div data-table="comp-03" class="comp js-draggable" draggable='true' ondragstart='onDragStart(event);' ondragend="onDragEnd(event);">
           [Text component]
         </div>

         <div data-table="comp-04" class="comp js-draggable" draggable='true' ondragstart='onDragStart(event);' ondragend="onDragEnd(event);">
           [Footer component]
         </div>
       </div>
     </div>
     <div class="col col-9">
       <h3>Dropzone</h3>
       <div id="dropzone" class="editor-view" ondragover='onDragOver(event);' ondrop='onDrop(event);'>
       </div>
     </div>

     <div class="hidden">
       <header class="actual-comp" id="comp-01">
         <a href="https://daily-dev-tips.com">
           <img src="https://daily-dev-tips.com/images/logo.png" height="50" />
         </a>
         <a href="#">Menu</a>
       </header>
       <div class="actual-comp" id="comp-02">
         <img class="image" src="https://images.unsplash.com/photo-1587588354456-ae376af71a25?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80" />
       </div>
       <div class="actual-comp" id="comp-03">
         <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer quis cursus massa, eget fringilla dolor. Praesent ligula libero, luctus sit amet urna a, semper scelerisque lorem. Curabitur efficitur, tortor in tempor elementum, orci quam mollis quam, nec fermentum lacus mauris eu nisl. Praesent elementum eros et justo faucibus, sed vestibulum mauris tincidunt. Aenean suscipit ultrices tellus, at aliquam diam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vivamus non maximus mauris, nec finibus risus. Donec sit amet massa malesuada, mollis mi nec, condimentum justo. Pellentesque velit ligula, feugiat eget nisi quis, mattis eleifend sem. Proin pretium risus ligula, a aliquet elit commodo sit amet.</p>
       </div>
       <footer class="actual-comp" id="comp-04">&copy; Daily Dev Tips 2020</footer>
     </div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  font-family: Roboto,"Helvetica Neue",Arial,sans-serif;
}
.container {
  min-height: 100vh;
  display: flex;
  padding: 1rem;

  .col {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
  }
  .col-3 {
    flex-basis: 25%;
  }
  .col-9 {
    flex-basis: 75%;
    h3 {
      text-align: center;
      margin-bottom: 0.5rem;
    }
  }
  .editor-view {
    border: 2px dotted #efefef;
    min-height: 400px;
    width: 100%;
  }
}

.comp {
  background: #2a9d8f;
  color: #fff;
  height: 50px;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}
.hidden {
  display: none;
}
.actual-comp {
  position: relative;
  max-width: 100%;
  &-remove {
    position: absolute;
    color: red;
    top: calc(50% - 12px);
    right: 15px;
    font-weight: bold;
    cursor: pointer;
    pointer-events: all;
  }
}

/*
 * These are all the components styled not really important for the actual purpose */
header {
  background: #264653;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0 1rem;
  a {
    color: #fff;
  }
}
.image {
  max-width: 100%;
  border-radius: 5px;
  border: 5px solid #efefef;
  margin: 0.5rem 0;
}
footer {
  background: #264653;
  color: #fff;
  height: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 0.5rem;
}
.text {
  margin: 0.5rem;
}

              
            
!

JS

              
                // Global vars
const dropzone = document.getElementById("dropzone");

function onDragStart(event) {
  event.dataTransfer.setData("text/plain", event.currentTarget.dataset.table);
  event.currentTarget.style.backgroundColor = "#e9c46a";
}

function onDragEnd(event) {
  event.currentTarget.style.backgroundColor = "#2a9d8f";
}

function onDragOver(event) {
  event.preventDefault();
}

function onDrop(event) {
  let id = event.dataTransfer.getData("text");

  const draggableElement = document.getElementById(id);
  const clone = draggableElement.cloneNode(true);

  dropzone.appendChild(clone);

  event.dataTransfer.clearData();
}

              
            
!
999px

Console