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="container">
  <div class="box orange" style="width: 50px; height: 75px;"><p>box 01</p></div>
  <div class="box all" style="width: 100px; height: 75px;"><p>box 02</p></div>
  <div class="box All" style="width: 50px; height: 100px;"><p>box 03</p></div>
  <div class="box Purple" style="width: 75px; height: 100px;"><p>box 04</p></div>
  <div class="box orange" style="width: 100px; height: 75px;"><p>box 05</p></div>
  <div class="box blue" style="width: 50px; height: 100px;"><p>box 06</p></div>
  <div class="box All" style="width: 100px; height:100px;"><p>box 07</p></div>
  <div class="box green" style="width: 75px; height: 75px;"><p>box 08</p></div>



                html {font-family: sans-serif;}

.box {
    cursor: move;
  	border: 1px solid black;
  	color: white;
	  font-weight: bold;
  	font-size: xx-small;

.Purple {background-color: purple;}
.orange {background-color: darkorange;}
.blue {background-color: blue;}
.green {background-color: green;}
.All {background-color: deeppink;}
.all {background-color: orangered;}

#container {width:700px; height:1500px;}
#container .ui-selecting {background-color: greenyellow; color: black;} /*while selecting*/
#container .ui-selected  {background-color: greenyellow; color: black;} /*selected*/

#container > div {position: absolute;} /*default box*/
.ui-selectable-helper {position: absolute; border:1px dotted black; background: rgba(76, 175, 80, 0.3)} /*selection laso*/

.box:hover { opacity: .5; -webkit-filter: grayscale(100%) }

p {display:inline;}




var positions = JSON.parse(localStorage.positions || "{}");
$(function () {
    var d = $(".box").attr("id", function (i) {
        return "draggable_" + i  + "_v1";  // Use "_v#" for version control
    $.each(positions, function (id, pos) {
        $("#" + id).css(pos);
        stop: function (event, ui) {
            positions[] = ui.position;
            localStorage.positions = JSON.stringify(positions);

// this creates the selected variable
// we are going to store the selected objects in here
var selected = $([]), offset = {top:0, left:0}; 

$( "#container > div" ).draggable({
    start: function(ev, ui) {
        if ($(this).hasClass("ui-selected")){
            selected = $(".ui-selected").each(function() {
               var el = $(this);
     "offset", el.offset());
        else {
            selected = $([]);
            $("#container > div").removeClass("ui-selected");
        offset = $(this).offset();
    drag: function(ev, ui) {
        var dt = -, dl = ui.position.left - offset.left;
        // take all the elements that are selected expect $("this"), 
        //which is the element being dragged and loop through each.
        selected.not(this).each(function() {
             // create the variable for we don't need to keep calling $("this")
             // el = current element we are on
             // off = what position was this element at when it was selected, before drag
             var el = $(this), off ="offset");
            el.css({top: + dt, left: off.left + dl});

$( "#container" ).selectable();

// STARTING LOCATION of the divs
var i = 0;
$("#container > div").each( function() {
   top: i * 20

 //  if (e.shiftKey) {
      var newTransform = $(this).css("transform") == 'none' ? "rotate(90deg)" : "";
      $(this).css("transform", newTransform);
        positions[].transform = newTransform;
      localStorage.positions = JSON.stringify(positions);
 //  }
$('.box').draggable({snap: true,});
//SNAP OVERIDE with altKey
$(window).on('keydown', function(event){
    if (event.keyCode == 18) {
            snap: false
$(window).on('keyup', function(event){
    if (event.keyCode == 18) {
            snap: true