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. 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

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

              
                <!-- LOADER -->
<div class="bar">
	<div id="loader" class="loader"></div>
</div>	
<!-- LOADER END -->


<div id="container">
   <div class="dragged">
		 <!-- DRAGGABLE DIV -->
    <div class="box" draggable="true" ondragstart="dragstart_handler(event);"></div>
		 <!-- DRAGGABLE DIV END -->
   </div>
  
<!-- 	DRAGGED DIVS -->
   <div class="dragged"></div>
	 <div class="dragged"></div>
<!-- 	DRAGGED DIVS END -->
</div>


<!-- FOLLOW -->
<a class="Follow" href="https://codepen.io/ZaynAlaoudi/" target="blank_"></a>

              
            
!

CSS

              
                body {
	background: #fff;
}
/* MAIN CONTENT || CENTERING DIVS */
#container {
	text-align: center;
	margin: 50px auto;
	width: 100%;
}
/* DRAGGABLE DIV */
.box {
	height: 390px;
	width: 205px;
	/* fallback for old browsers */
	background: -webkit-linear-gradient(to right, #E100FF, #7F00FF);
	/* Chrome 10-25, Safari 5.1-6 */
	background: -webkit-gradient(linear, left top, right top, from(#E100FF), to(#7F00FF));
	background: -webkit-linear-gradient(left, #E100FF, #7F00FF);
	background: -o-linear-gradient(left, #E100FF, #7F00FF);
	background: linear-gradient(to right, #E100FF, #7F00FF);
	/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
	margin: 10px auto;
	border-radius: 30px;
	cursor: pointer;
}
/* DRAGGABLE DIV END */


.heldOf {
	background: #B2FEFA;
	/* fallback for old browsers */
	background: -webkit-linear-gradient(to right, #0ED2F7, #B2FEFA);
	/* Chrome 10-25, Safari 5.1-6 */
	background: -webkit-gradient(linear, left top, right top, from(#0ED2F7), to(#B2FEFA));
	background: -webkit-linear-gradient(left, #0ED2F7, #B2FEFA);
	background: -o-linear-gradient(left, #0ED2F7, #B2FEFA);
	background: linear-gradient(to right, #0ED2F7, #B2FEFA);
	/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
	border-radius: 30px;	
}

.dragged {
	height: 410px;
	width: 220px;
	margin: 15px;
	display: inline-block;
	-webkit-transition: 200ms ease-in-out;
	-o-transition: 200ms ease-in-out;
	-webkit-transition: 0.3s ease-in-out;
	-o-transition: 0.3s ease-in-out;
	transition: 0.3s ease-in-out;
	border-radius: 30px;
	-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.hoveredOf {
	padding: 10px;
	-webkit-box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
	box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}
.box::after {
	content: '';
	display: block;
	width: 0;
	height: 4px;
	background: lightgreen;
	margin: 0 auto;
	border-radius: 10px;
	-webkit-transition: width .9s;
	-o-transition: width .9s;
	transition: width .9s;
}
.box:hover::after {
	width: 70%;
	-webkit-transition: width 1.9s;
	-o-transition: width 1.9s;
	transition: width 1.9s;
}


.bar {
	margin: 0;
	height: 10px;
	width: 100%;
	position: absolute;
	top: 0;
	left: 0;
}
#loader {
	width: 0%;
	height: 4.1px;
	background: -webkit-linear-gradient(326deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
	background: -o-linear-gradient(326deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
	background: linear-gradient(124deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
	-webkit-animation: expand 4s ease-in-out infinite;
	animation: expand 4s ease-in-out infinite;
	
	
}
@-webkit-keyframes expand {
	to {
		width: 100%;
	}
}
@keyframes expand {
	to {
		width: 100%;
	}
}

/*  FOLLOW*/
.Follow {	  background:url("https://pbs.twimg.com/profile_images/959092900708544512/v4Db9QRv_bigger.jpg")no-repeat center / contain;
	width: 50px;
	height: 50px;
	bottom: 9px;
	right: 20px;
	display:block;
	position:fixed;
	border-radius:50%;
	z-index:999;
	animation:  rotation 10s infinite linear;
	}

@-webkit-keyframes rotation {
		from {
				-webkit-transform: rotate(0deg);
		}
		to {
				-webkit-transform: rotate(359deg);
		}
}
              
            
!

JS

              
                class App {

	static init() {
		App.box = document.getElementsByClassName('box')[0]
		App.box.addEventListener("dragstart", App.dragstart)
		App.box.addEventListener("dragend", App.dragend)

		const containers = document.getElementsByClassName('dragged')
		for (const container of containers) {
			container.addEventListener("dragover", App.dragover)
			container.addEventListener("dragenter", App.dragenter)
			container.addEventListener("dragleave", App.dragleave)
			container.addEventListener("drop", App.drop)
		}
	}

	static dragstart() {
		this.className += " heldOf"

		setTimeout(() => this.className = "invisible", 0)
	}
	static dragend() {
		this.className = "box"
	}

	static dragover(e) {
		e.preventDefault()
	}

	static dragenter(e) {
		e.preventDefault()
		this.className += " hoveredOf"
	}
	static dragleave() {
		this.className = "dragged"
	}
	static drop() {
		this.className = "dragged"
		this.append(App.box)
	}
}


document.addEventListener("DOMContentLoaded", App.init)




// VANISHING WHEN TRYING ON FIREFOX || THIS FUNCTION SHOULD FIX THE PROBLEM

// FOR FIREFOX ONLY ||
function dragstart_handler(ev) {
 console.log("dragStart");
 // Add the target element's id to the data transfer object
 ev.dataTransfer.setData("text/plain", ev.target.id);
}

              
            
!
999px

Console