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

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.

HTML

              
                <div class="container">
<img class="laptop" 
  srcset="https://leniolabs.com/images/l-layoutit-mob.jpg 470w, https://leniolabs.com/images/l-layoutit.jpg" 
     sizes="(max-width: 470px) 100%, 100%"
  src="https://leniolabs.com/images/l-layoutit.jpg" alt="layoutit">
      <i class="laptop-base"></i>
</div>
<p>Collapse your browser to make the viewport 330px or so, (if you are on chrome reload the page). Start expanding the viewport to the maximum.<br> <a target="_blank" href="https://dribbble.com/shots/5421819-Responsive-images-with-srcset-and-CSS-illustrations?utm_source=Clipboard_Shot&utm_campaign=marianabelda&utm_content=Responsive%20images%20with%20srcset%20and%20CSS%20illustrations&utm_medium=Social_Share">GIF example in dribbble</a></p>
              
            
!

CSS

              
                * { box-sizing: border-box; }
body {
  background-color: #00435e;
  color: white;
  font-family: 'Lato', 'Lucida Grande', 'Lucida Sans Unicode', Tahoma, Sans-Serif;
  margin:0;
  text-align:center;
}
img { width:100%; }
a { color: #ff9900; }
p {
  line-height: 1.4;
  margin: 0 auto;
  max-width: 58ch;
}
.container {
  margin: 2em auto;
  max-width: 40em;
  width: 80%;
}
.laptop {
    background: radial-gradient(100% 100% at 50% 50%, rgba(0, 0, 0, 0.4) 49%, transparent 50%) -26px 50%/20px 20px, linear-gradient(0deg, rgba(0, 0, 0, 0.4) 100%, transparent 0) calc(100% + 15px) 50%/6px 80px;
    background-repeat: no-repeat;
    border: 24px solid rgba(0, 0, 0, 0.3);
    border-left-width: 32px;
    border-radius: 15px;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.4);
    transition: background .5s ease-in-out;
}

@media screen and (min-width: 56.25em) {
  .laptop {
      background: radial-gradient(100% 100% at 50% 50%, rgba(0, 0, 0, 0.4) 49%, transparent 50%) 50% -14px/10px 10px;
      background-repeat: no-repeat;
      border-width: 15px 10px 30px;
  }
  .laptop-base {
    background-color: #051d27;
    border-radius: 0 0 15px 15px;
    display: block;
    height: 24px;
    margin-left: -5%;
    margin-top: -20px;
    position: relative;
    width: 110%;
  }
  .laptop-base:after {
      content: "";
      background-color: rgba(255, 255, 255, 0.2);
      border-radius: 0 0 5px 5px;
      display: block;
      height: 5px;
      margin: 0 auto;
      width: 50px;
  }
}

@media screen and (max-width: 470px) {
  .laptop {
      background: radial-gradient(100% 100% at 50% 50%, rgba(0, 0, 0, 0.4) 49%, transparent 50%) 50% calc(100% + 36px)/30px 30px, linear-gradient(90deg, rgba(0, 0, 0, 0.4) 100%, transparent 0) 50% -20px/80px 6px;
      background-repeat: no-repeat;
      border-width: 45px 10px;
      min-height: 480px;
      max-height: 90vh;
      object-fit: cover;
      object-position: top left;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console