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

              
                html
  .window( style="z-index: 98; top: 125px; left: 505px; width: 378px; height: 371px;" )
    .bar
      .bar-left
        .bar-left-button
          svg
            rect( id="Rectangle" stroke="#000000" x="4" y="9.5" stroke-width="3px" fill="#E6E6E6" width="18" height="6" rx="3")
      .bar-middle
        .bar-middle-content villalobos_done.bmp
        .bar-middle-button
      .bar-right
        .bar-right-button
    .header
      button.header__item File
      button.header__item Edit
      button.header__item Help
    .content
      img(src="https://lastfm.freetls.fastly.net/i/u/770x0/63b8f38b6ae34ff09d1d464cf8dcec50.jpg")
  
  .window( style="z-index: 99; top: 30px; left: 41px; width: 375px; height: 461px;" )
    .bar
      .bar-left
        .bar-left-button
          svg
            rect( id="Rectangle" stroke="#000000" x="4" y="9.5" stroke-width="3px" fill="#E6E6E6" width="18" height="6" rx="3")
      .bar-middle
        .bar-middle-content villalobos_presentable.jpg
        .bar-middle-button
      .bar-right
        .bar-right-button
    .header
      button.header__item File
      button.header__item Edit
      button.header__item Help
    .content
      img(src="https://thumbnailer.mixcloud.com/unsafe/600x600/extaudio/d/5/4/d/32a8-1cb8-40bd-b2f8-f7a462d6eec7")
   
  .window( style="z-index: 100; top: 69px; left: 1040px; width: 380px; height: 401px;" )
    .bar
      .bar-left
        .bar-left-button
          svg
            rect( id="Rectangle" stroke="#000000" x="4" y="9.5" stroke-width="3px" fill="#E6E6E6" width="18" height="6" rx="3")
      .bar-middle
        .bar-middle-content Paint
        .bar-middle-button
      .bar-right
        .bar-right-button
    .header
      button.header__item File
      button.header__item Edit
      button.header__item Help
    .content
       <iframe src="https://jspaint.app/" id="paint"></iframe> 



              
            
!

CSS

              
                @use postcss-nested;

/* don't remove this comment */

:root {
  --border-color: #000;
  --border-width: 3px;
  --bg-color: #438F92;
  --txt-color: var(--border-color);
  --button-color: #A6A6A6;
  --window-bg-color: #B8B4AE;
  --bar-bg-color: #EDEDED;
  --header-bg-color: #D9D9D9;
} 

/* resset */
button {
  appearance: none;
  outline: none;
  border: none;
  background-color: unset;
  color: inherit;
  font-weight: inherit;
  font-size: inherit;
  font-family: inherit;
  line-height: unset;
  margin: unset;
  padding: unset;
}

html {
  padding: 2rem;
  background-color: var(--bg-color);
  
  font-family: "Arial", sans-serif;
  font-weight: 600;
  color: var(--txt-color);
}

.window {
  width: 480px;
  height: 360px;
  background-color: var(--window-bg-color);
  box-shadow:0 0 0 var(--border-width) var(--border-color);
  
  display: grid;
  grid-gap: 3px;
  grid-template-rows: 2rem calc(2rem - var(--border-width)) auto;
  
  z-index: 9;
  position: absolute;
  
  
  &:hover, &:active {
    resize: both;
    overflow: auto;
  }
}

.content {
  overflow: hidden;
  margin: calc(2 * var(--border-width));
  margin-top: 0; /* pull content to header */
  box-shadow:0 0 0 var(--border-width) var(--border-color);
  
  * {
    object-fit: cover;
    height: 100%;
    width: 100%;
  }
}

.bar {
  height: 2rem;
  width: 100%;
  
  display: grid;
  grid-gap: var(--border-width);
  grid-template-columns: 2rem auto 2rem;
  
  box-sizing: border-box;
}

.bar-left, .bar-middle, .bar-right {
  height: 2rem;
  box-shadow:0 0 0 var(--border-width) var(--border-color);
  
  display: flex;
  flex-direction: row;

}

.bar-left-button, .bar-middle-content, .bar-middle-button, .bar-right-button {
  display: inline-block;
  margin-top: calc(2 * var(--border-width));
  
  height: calc(2rem - var(--border-width) - var(--border-width));
  box-shadow:0 0 0 var(--border-width) var(--border-color);
  
  text-align: center;
  line-height: calc(2rem - (2 * var(--border-width)));
}

.bar-middle-button, .bar-right-button, .bar-left-button {
  width: calc(2rem - var(--border-width));
  background-color: var(--button-color);
}

.bar-middle-content { width: calc(100% - 2rem + var(--border-width))}
.bar-middle-button { margin-left: var(--border-width) }
.bar-left-button { margin-left: calc(2 * var(--border-width)) }
.bar-right-button { margin-right: calc(2 * var(--border-width)) }


.bar-middle-content {
  padding-left: calc(2rem - var(--border-width));
  background-color: var(--bar-bg-color);
}

.header {
  padding: 0 var(--border-width);
  margin: 0 calc(2 * var(--border-width));
  box-shadow: 0 0 0 var(--border-width) var(--border-color);
  background-color: var(--header-bg-color);
  
  &__item {
    height: 100%;
    padding: .3rem .6rem;
    margin: 0 calc(-1 * var(--border-width));
    
    &::first-letter {
      text-decoration: underline;
    }
    
    &:hover {
      background-color: #B9B9B9;
    }
  }
}

#paint {
  /* hide the top and bottom bars */
  margin-top: -20px;
  margin-bottom: -20px;
  height: calc(100% + 20px + 20px);
}
              
            
!

JS

              
                window.onload = function() {
  initDragElement();
};

function initDragElement() {
  var pos1 = 0,
    pos2 = 0,
    pos3 = 0,
    pos4 = 0;
  var popups = document.getElementsByClassName("window");
  var elmnt = null;
  var currentZIndex = 100; //TODO reset z index when a threshold is passed

  for (var i = 0; i < popups.length; i++) {
    var popup = popups[i];
    var header = getHeader(popup);

    popup.onmousedown = function() {
      this.style.zIndex = "" + ++currentZIndex;
    };

    if (header) {
      header.parentPopup = popup;
      header.onmousedown = dragMouseDown;
    }
  }

  function dragMouseDown(e) {
    elmnt = this.parentPopup;
    elmnt.style.zIndex = "" + ++currentZIndex;

    e = e || window.event;
    // get the mouse cursor position at startup:
    pos3 = e.clientX;
    pos4 = e.clientY;
    document.onmouseup = closeDragElement;
    // call a function whenever the cursor moves:
    document.onmousemove = elementDrag;
  }

  function elementDrag(e) {
    if (!elmnt) {
      return;
    }

    e = e || window.event;
    // calculate the new cursor position:
    pos1 = pos3 - e.clientX;
    pos2 = pos4 - e.clientY;
    pos3 = e.clientX;
    pos4 = e.clientY;
    // set the element's new position:
    elmnt.style.top = elmnt.offsetTop - pos2 + "px";
    elmnt.style.left = elmnt.offsetLeft - pos1 + "px";
  }

  function closeDragElement() {
    /* stop moving when mouse button is released:*/
    document.onmouseup = null;
    document.onmousemove = null;
  }

  function getHeader(element) {
    var headerItems = element.getElementsByClassName("bar");

    if (headerItems.length === 1) {
      return headerItems[0];
    }

    return null;
  }
}

function initResizeElement() {
  var popups = document.getElementsByClassName("window");
  var element = null;
  var startX, startY, startWidth, startHeight;

  for (var i = 0; i < popups.length; i++) {
    var p = popups[i];

    var right = document.createElement("div");
    right.className = "resizer-right";
    p.appendChild(right);
    right.addEventListener("mousedown", initDrag, false);
    right.parentPopup = p;

    var bottom = document.createElement("div");
    bottom.className = "resizer-bottom";
    p.appendChild(bottom);
    bottom.addEventListener("mousedown", initDrag, false);
    bottom.parentPopup = p;

    var both = document.createElement("div");
    both.className = "resizer-both";
    p.appendChild(both);
    both.addEventListener("mousedown", initDrag, false);
    both.parentPopup = p;
  }

  function initDrag(e) {
    element = this.parentPopup;

    startX = e.clientX;
    startY = e.clientY;
    startWidth = parseInt(
      document.defaultView.getComputedStyle(element).width,
      10
    );
    startHeight = parseInt(
      document.defaultView.getComputedStyle(element).height,
      10
    );
    document.documentElement.addEventListener("mousemove", doDrag, false);
    document.documentElement.addEventListener("mouseup", stopDrag, false);
  }

  function doDrag(e) {
    element.style.width = startWidth + e.clientX - startX + "px";
    element.style.height = startHeight + e.clientY - startY + "px";
  }

  function stopDrag() {
    document.documentElement.removeEventListener("mousemove", doDrag, false);
    document.documentElement.removeEventListener("mouseup", stopDrag, false);
  }
}

              
            
!
999px

Console