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 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");