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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <figure class="devices">
  <div class="device laptop">
    <div id="laptop" class="device-screen">
      <img src="https://properdesign.co.uk/wp-content/uploads/2015/01/screencapture-botanicgarden-wales-2018-05-09-14_37_36.jpg"> </div>
  </div>
  <div class="device mobile">
    <div id="mobile" class="device-screen">
      <img src="https://properdesign.co.uk/wp-content/uploads/2015/01/screencapture-botanicgarden-wales-2018-05-09-14_38_13.jpg">      </div>
  </div>
  <div class="device tablet">
    <div id="tablet" class="device-screen">
      <img src="https://properdesign.co.uk/wp-content/uploads/2015/01/screencapture-botanicgarden-wales-2018-05-09-14_38_48.jpg">      </div>
  </div>
</figure>
            
          
!

CSS

            
              html,
body{
  margin:0;
  padding:0;
}
*{
  box-sizing:border-box;
}
.devices{
  background-color:#eaeaea;
  margin: 0;
  display:grid;
  grid-template-columns:repeat(20, 5vw);
  grid-auto-rows:5vw;
  padding-bottom:5vw;
}

.device{
  background-color:black;
  position: relative;
  border:solid 0.5vw black;
  box-shadow:0 0.25vw 0.5vw rgba(0,0,0,0.2);
}


.device-screen{
  width:100%;
  height:100%;
  background-color:black;
  overflow:hidden;
  overflow-y:scroll;
  img{
    display:block;
    width:100%;
    height:auto;
    margin:0;
  }
}


.mobile{
  border-top:solid 1vw black;
  border-bottom:solid 2vw black;
  grid-column:2 / span 3;
  grid-row: 3 / span 6;
  border-radius:1.5vw;
  .device-screen{
    border-radius:1vw;
  }
}

.tablet{
  border-left:solid 2vw black;
  grid-column:13 / span 7;
  grid-row: 4 / span 5;
  border-radius:1vw;
  .device-screen{
    border-radius:0.5vw;
  }

}
.laptop{
  grid-column:3/span 13;
  grid-row: 2 / span 8;
  border:solid 1vw #999999;
  &:after{
    content:"";
    position:absolute;
    bottom:-3vw;
    left:-7.5vw;
    right:-7.5vw;
    height:3vw;
    background-color:#999999;
    border-radius: 0 0 1vw 1vw;
  }
}
            
          
!

JS

            
              // ret our screens
const screens = Array.from(document.getElementsByClassName('device-screen'))
 
screens.forEach(screen => { 
  // Add scroll function when controlling a device
  screen.addEventListener('mouseover', function(e) {
    screen.addEventListener('scroll', scrollAll)
  })
  screen.addEventListener("touchstart", function(e) {
    screen.addEventListener("scroll", scrollAll);
  });
  // Remove them when we leave the device
  screen.addEventListener('mouseleave', function(e) {
    screen.removeEventListener('scroll', scrollAll)
  })
  screen.addEventListener("touchend", function(e) {
    screen.removeEventListener("scroll", scrollAll);
  });
})
  
const scrollAll = e => {
  // Calculate the size and scroll position of the device we're controlling
  const screenHeight = e.target.clientHeight;
  const scrollPoint = e.target.scrollHeight;
  const scroll = e.target.scrollTop;
  // Work out the percentage scrolled on this device
  const scrollPercentage = scroll / (scrollPoint - screenHeight);

  // Scroll the other devices to the same relevant position on the page
  screens.forEach(screen => {
    if (screen !== e.target) {
      // Work out the visible height of this screen and multiply it by the percentage of the parent screen
      screen.scrollTo(
        0,
        (screen.scrollHeight - screen.clientHeight) * scrollPercentage
      );
    }
  });
};
            
          
!
999px

Console