Pen Settings



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


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.


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.


.droptarget {
  float: left; 
  width: 150px; 
  height: 55px;
  margin: 15px;
  padding: 10px;
  border: 1px solid gray;

<div class="droptarget">
  <p draggable="true" id="dragtarget"></p>

<div class="droptarget"></div>

<p id="demo"></p>

/* Drag 대상에 촉발된 이벤트 */    
document.addEventListener("dragstart", function(event) { // P요소 드래그 시작 후
  event.dataTransfer.setData("Text",; // 드래그된 데이터 타입과 값 지정.  
  document.getElementById("demo").innerHTML = "p 요소 드래그 시작."; = "0.4"; // 드래그중 요소의 투명도 조정

document.addEventListener("drag", function(event) { // P요소 드래그 중
  document.getElementById("demo").style.color = "red"; 

document.addEventListener("dragend", function(event) { // P요소 드래그 완료 후
  document.getElementById("demo").innerHTML = "p 요소 드래그 완료."; = "1";

/* Drop 대상에 촉발된 이벤트 */

document.addEventListener("dragenter", function(event) { // div요소에 들어올 때
  if ( == "droptarget" ) { = "3px dotted red";

document.addEventListener("dragover", function(event) { // 요소 드롭방지 기본동작 차단. (= 드롭 허용)

document.addEventListener("dragleave", function(event) { // div요소를 떠날 때
  if ( == "droptarget" ) { = "";

document.addEventListener("drop", function(event) {
  event.preventDefault(); // 드롭시 링클로 열리는 기본동작차단 (= 단순이동)
  if ( == "droptarget" ) {
    document.getElementById("demo").style.color = ""; = "";
    var data = event.dataTransfer.getData("Text"); // 이동된 데이터 가져오기;