cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              div(id="device" class="phone")
  div(id="browser-bar")
    input(id="url-bar" type="url" placeholder="website address" value="material.io" spellcheck="false")
    div(class="device-menu-button-wrapper")
      button(id="device-menu-button" class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect")
        i(class="material-icons") more_vert
    ul(class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="device-menu-button")
      li(class="mdl-menu__item device-button" device="phone")
        i(class="material-icons") smartphone
        | Phone
      li(class="mdl-menu__item device-button" device="tablet")
        i(class="material-icons") tablet
        | Tablet
      li(class="mdl-menu__item device-button" device="laptop")
        i(class="material-icons") laptop
        | Laptop
      li(class="mdl-menu__item device-button" device="desktop")
        i(class="material-icons") desktop_windows
        | Dekstop
  iframe(id="iframe" src="" sandbox="allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-forms")
            
          
!
            
              $black-1: rgba(#000, 0.87);
$black-2: rgba(#000, 0.54);
$stn-t: 400ms;
$srt-t: $stn-t * 0.5;
$lng-t: $stn-t * 1.5;
$stn-c: cubic-bezier(0.4, 0.0, 0.2, 1);
$dec-c: cubic-bezier(0.0, 0.0, 0.2, 1);
;

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #eee;
  color: $black-1;
  text-rendering: optimizeLegibility;
  font-family: "Roboto", sans-serif;
  overflow: hidden;
}

#device {
  animation: slide-in-up $lng-t $dec-c;
  transition: $stn-t $dec-c;
  z-index: 1;
  flex-shrink: 0;
  border-radius: 2px;
  box-shadow: 0 16px 24px 2px rgba(0,0,0,.15), 0 6px 30px 5px rgba(0,0,0,.1), 0 8px 10px -5px rgba(0,0,0,.2);
  overflow: hidden;
  &.phone {
    width: 360px;
    height: 640px;
  } &.tablet {
    width: 1024px;
    height: 768px;
  } &.laptop {
    width: 1366px;
    height: 768px;
  } &.desktop {
    width: 1600px;
    height: 900px;
  }
}

#browser-bar {
  z-index: 3;
  position: relative;
  display: flex;
  align-items: center;
  align-content: center;
  justify-content: center;
  width: 100%;
  height: 3rem;
  box-shadow: 0 1px 3px 0 rgba(#000, 0.25), 0 0 5px 0 rgba(#000, 0.2);
  background: #fff;
}

#url-bar {
  border: 0;
  margin: 0;
  z-index: 5;
  transition: $srt-t $stn-c;
  width: calc(100% - 6rem);
  max-width: calc(6rem + 40%) ;
  height: 2rem;
  outline: 0;
  border-radius: 2px;
  padding: 0 0.5rem;
  box-shadow: 0 2px 2px 0 rgba(0,0,0,.15), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.1);
  text-align: center;
  font-family: "Roboto", "Helvetica Neue", "Helvetica", sans-serif;
  font-size: 1rem;
  &:focus {
    box-shadow: 0 3px 4px 0 rgba(0,0,0,.15), 0 3px 3px -2px rgba(0,0,0,.2), 0 1px 8px 0 rgba(0,0,0,.1)
  }
  &::placeholder {
    color: rgba(0,0,0,.34);
    font-weight: 500;
  }
}

.device-menu-button-wrapper {
  z-index: 4;
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  height: 2.5rem;
  user-select: none;
  & #device-menu-button {
    width: 2.5rem;
    height: 2.5rem;
    outline: 0;
    & .mdl-button__ripple-container {
      overflow: hidden;
    }
  }
}

.mdl-menu__container {
  top: 0.25rem !important;
  right: 0.25rem !important;  
  overflow: hidden;
  & .mdl-menu {
    padding: 0;
     & .material-icons {
      padding-right: 1rem;
      color: $black-2;
      vertical-align: middle;
    }
  }
}

#iframe {
  z-index: 2;
  width: 100%;
  height: calc(100% - 3rem);
  background: #fff;
}

#curtain {
  animation: fade-in $stn-t $stn-c;
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: $black-2;
}

#warning {
  z-index: 1001;
  width: 17rem;
  border-radius: 2px;
  box-shadow: 0 9px 46px 8px rgba(0,0,0,.15), 0 11px 15px -7px rgba(0,0,0,.1), 0 24px 38px 3px rgba(0,0,0,.2);
  background: #fff;
  font-weight: 500;
  & .material-icons {
    display: inline-block;
    padding: 1rem;
    color: #f44336;
    vertical-align: middle;
    font-size: 3rem;
    user-select: none;
  } & .warning-text {
    display: inline-block;
    width: 12rem;
    padding: 1.5rem 1.5rem 1.5rem 0;
    color: $black-2;
    vertical-align: middle;
    line-height: 1.5em;
  }
}

@keyframes slide-in-up {
  0% {
    transform: translateY(200vh);
  } 100% {
    transform: translateY(0);
  }
}

@keyframes fade-in {
  0% {
    opacity: 0;
  } 100% {
    opacity: 1;
  }
}
            
          
!
            
              // # global variables

var curtain = document.getElementById('curtain');
var deviceButtons = document.getElementsByClassName('device-button');
var device = document.getElementById('device');
var urlBar = document.getElementById('url-bar');
var iframe = document.getElementById('iframe');

// # size

for (let i = 0; i < deviceButtons.length; i++) {
  deviceButtons[i].onclick = () => {
    device.className = deviceButtons[i].getAttribute('device');
  }
}

// # URL

function visit() {
  var url = urlBar.value;
  if (url.indexOf('http://') < 0 && url.indexOf('https://') < 0) {
    url = 'http://' + url;
  } else if (url.indexOf('http://') >= 0) {
    urlBar.value = urlBar.value.split('http://')[1];
  }
  iframe.setAttribute('src', url);
}

visit();

urlBar.onchange = () => {
  visit();
}

urlBar.onfocus = () => {
  urlBar.select();
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console