Pen Settings

HTML

CSS

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

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

              
                <div class="window">
  <aside>
    <nav>
      <ul>
        <li></li>
        <li></li>
        <li></li>
      </ul>    
    </nav>
    <div class="aside-content">
      <details open>
        <summary>Favorite</summary>
        <ul>
          <li>Recent</li>
          <li>Yexan</li>
          <li>Images</li>
          <li>Documents</li>
          <li>Apps</li>
          <li class="active">Desktop</li>
          <li>Downloads</li>
        </ul>
      </details>
      <details open>
        <summary>Connected</summary>
        <ul>
          <li>Network</li>
          <li>Hard Drive</li>
          <li>Hard Drive</li>
        </ul>
      </details>
    </div>
  </aside>
  <main>
    <nav>
      Desktop
    </nav>
    <div class="main-content">
      
    </div>
  </main>
</div>
              
            
!

CSS

              
                .window
  position: fixed
  top: 70px
  left: 120px
  width: 650px
  height: 350px
  display: grid
  grid-template-columns: 200px 1fr
  border-radius: 10px
  box-shadow: 5px 5px 25px -2px rgba(0,0,0,.4) 
  overflow: auto
    
aside
  position: relative
  padding: 0
  margin: 0
  backdrop-filter: blur(25px)
  
  nav
    position: absolute
    top: 0
    left: 0
    right: 0
    padding: 20px 15px
    z-index: 2
    cursor: move
    
    ul
      display: flex
      flex-direction: row
      align-items: center
      justify-content: flex-start
    
    li
      width: 13px
      height: 13px
      padding: 0
      border-radius: 10px
      cursor: pointer
      
      &:before
        background: none
    
      & + li
        margin-left: 10px
        
      &:nth-child(1)
        background: #E53935
      
      &:nth-child(2)
        background: #FFCA28
      
      &:nth-child(3)
        background: #8BC34A
  
  .aside-content
    position: absolute
    top: 50px
    bottom: 0
    left: 0
    right: 0
    padding: 0px 15px 15px
    overflow: auto
    
  details
    & + details
      margin-top: 15px
  
  summary
    margin-bottom: 2px
    font-size: .85em
    font-weight: bold
    color: rgba(0, 0, 0, .7)
    cursor: pointer
  
  ul
    margin: 0
    padding: 0 0 0 5px
    list-style: none
  
  li
    position: relative
    padding: 5px 0 5px 35px
    color: rgba(255, 255, 255, .8)
    border-radius: 5px
    cursor: pointer
    
    &.active
      background: rgba(255, 255, 255, .1)
      
    &:before
      content: ''
      position: absolute
      top: 4px
      left: 8px
      width: 20px
      height: 20px
      background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 298.757 298.757'%3E%3Cpath fill='%2357F' d='M291.701,119.091h-39.95v-29.61c0-3.893-3.156-7.05-7.05-7.05h-95.549l-16.896-35.955 c-1.162-2.472-3.648-4.051-6.381-4.051H7.05c-3.893,0-7.05,3.157-7.05,7.05v199.806c0,3.846,3.135,7.051,7.054,7.051 c0.004,0,0.008-0.001,0.012-0.001h237.635c2.923,0,5.543-1.805,6.587-4.536l47-123.14 C300.048,124.044,296.635,119.091,291.701,119.091z M14.1,56.526h107.299l16.896,35.955c1.162,2.472,3.648,4.051,6.381,4.051 h92.975v22.56H54.05c-2.923,0-5.544,1.805-6.587,4.536L14.1,211.04V56.526z M239.846,242.231H17.287l41.618-109.04 c10.158,0,212.404,0,222.559,0L239.846,242.231z'/%3E%3C/svg%3E") no-repeat
      background-size: 90%

main
  position: relative
  padding: 0
  margin: 0
  
  nav
    position: absolute
    top: 0
    left: 0
    right: 0
    display: flex
    flex-direction: row
    align-items: center
    padding: 0 20px
    height: 50px
    color: rgba(255, 255, 255, .8)
    background: rgba(20, 20, 20, 1)
    z-index: 2
    cursor: move
    
.main-content
  position: absolute
  top: 50px
  bottom: 0
  left: 0
  right: 0
  padding: 0px 15px 15px
  background: rgba(10, 10, 10, .95)
  overflow: auto

  
body
  height: 100vh
  margin: 0
  padding: 0
  font-family: Arial
  background-image: url('https://images.unsplash.com/photo-1653579636217-0a062a1390ed?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2940&q=80')
  background-size: cover
  background-position: center
  background-repeat: no-repeat
              
            
!

JS

              
                let pos1 = 0
let pos2 = 0
let pos3 = 0
let pos4 = 0

// Draggalbe window element
const win = document.querySelector('.window')

const dragMouseDown = (evt: MouseEvent) => {
  evt = evt || window.event
  evt.preventDefault()
  pos3 = evt.clientX
  pos4 = evt.clientY
  document.onmouseup = closeDragElement
  document.onmousemove = elementDrag
}

const elementDrag = (evt: MouseEvent) => {
  evt = evt || window.event
  evt.preventDefault()
  pos1 = pos3 - evt.clientX
  pos2 = pos4 - evt.clientY
  pos3 = evt.clientX
  pos4 = evt.clientY
  win.style.top = (win.offsetTop - pos2) + 'px'
  win.style.left = (win.offsetLeft - pos1) + 'px'
}

const closeDragElement = () => {
  document.onmouseup = null
  document.onmousemove = null
} 


// Grabbed element allowed to move the window
const asideNav = document.querySelector('.window aside nav')
const mainNav = document.querySelector('.window main nav')

asideNav.onmousedown = dragMouseDown
mainNav.onmousedown = dragMouseDown

              
            
!
999px

Console