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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


<div id="drap" draggable="true"></div>
<div id="box"></div>
<img id="pic" src="" width="50" height="50"/>


              h2 {
#drap {
	width: 100px;
	height: 100px;
	background: red;
#box {
	width: 500px;
	height: 500px;
	border: 2px solid blue;
	margin: 50px auto;


              var drap = document.getElementById("drap");
var box = document.getElementById("box");
var pic = document.getElementById("pic");

drap.ondragstart = function(ev){ // 拖拽前
	var ev = ev || window.event;
	//effectAllowed : 设置光标样式(none, copy, copyLink, copyMove, link, linkMove,move, all 和uninitialized)
	ev.dataTransfer.effectAllowed = "copy";
	//设置被拖拽的小元素 setDragImage :三个参数(指定的元素,坐标X,坐标Y)
	ev.dataTransfer.setDragImage(pic,25,25); = "green";

drap.ondrag = function(){ // 拖拽过程中
	this.innerText = "被拖拽中...";

drap.ondragend = function(){ // 拖拽结束 = "red";
	this.innerHTML = "";

box.ondragenter = function(){ //进入目标元素触发
	this.innerHTML = "可将文件拖放到这里!";
box.ondragover = function(ev){ //进入目标、离开目标之间,连续触发
	var ev = ev || window.event;
	ev.preventDefault(); = "pink";
box.ondragleave = function(){ //离开目标元素触发
	this.innerHTML = ""; = "none";
box.ondrop = function(ev){//在目标元素上释放鼠标触发
	this.innerHTML = ev.dataTransfer.getData("key");