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

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

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

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


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

<script>
/* Drag 대상에 촉발된 이벤트 */    
  
document.addEventListener("dragstart", function(event) { // P요소 드래그 시작 후
  event.dataTransfer.setData("Text", event.target.id); // 드래그된 데이터 타입과 값 지정.  
  document.getElementById("demo").innerHTML = "p 요소 드래그 시작.";  
  event.target.style.opacity = "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 요소 드래그 완료.";
  event.target.style.opacity = "1";
});

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

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

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

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

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

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console