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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="container=fluid">

  <p><a href="https://codepen.io/JacobLett/pen/YWZOro">Aspect Ratio Calculator</a></p>
  
  <p class="alert-warning"><strong>?</strong> Do you want to have a consistent proportion as the image scales or do you want to have a controlled image height?</p>
  <h3>Constrained height of 400px</h3>
  
  <p><strong>Responsive image sizes:</strong> 600x400, 800x400, 1400x400, 2000x400</p>
  

<!--  Need IE11 support? https://scottjehl.github.io/picturefill/  -->
       <picture>
        <source srcset="https://dummyimage.com/2000x400/000/fff" media="(min-width: 1400px)">
        <source srcset="https://dummyimage.com/1400x400/000/fff" media="(min-width: 768px)">
         <source srcset="https://dummyimage.com/800x400/000/fff" media="(min-width: 576px)">
        <img srcset="https://dummyimage.com/600x400/000/fff" alt="responsive image" class="img-fluid">
      </picture>
  
  
    <h3>Constrained aspect ratio of 21:9</h3>
  <p><strong>Responsive image sizes:</strong> 600x257, 800x343, 1400x514, 2000x857</p>
  
  <!--  Need IE11 support? https://scottjehl.github.io/picturefill/  -->
       <picture>
        <source srcset="https://dummyimage.com/2000x857/000/fff" media="(min-width: 1400px)">
        <source srcset="https://dummyimage.com/1400x514/000/fff" media="(min-width: 768px)">
         <source srcset="https://dummyimage.com/800x343/000/fff" media="(min-width: 576px)">
        <img srcset="https://dummyimage.com/600x257/000/fff" alt="responsive image" class="img-fluid">
      </picture>
  
  
  
  
  
  <h3>Constrained aspect ratio of 16:9</h3>
  <p><strong>Responsive image sizes:</strong> 600x338, 800x450, 1400x675, 2000x1125</p>
  
  <!--  Need IE11 support? https://scottjehl.github.io/picturefill/  -->
       <picture>
        <source srcset="https://dummyimage.com/2000x1125/000/fff" media="(min-width: 1400px)">
        <source srcset="https://dummyimage.com/1400x675/000/fff" media="(min-width: 768px)">
         <source srcset="https://dummyimage.com/800x450/000/fff" media="(min-width: 576px)">
        <img srcset="https://dummyimage.com/600x338/000/fff" alt="responsive image" class="img-fluid">
      </picture>
  
  
    <h3>Constrained aspect ratio of 4:3</h3>
  <p><strong>Responsive image sizes:</strong> 600x450, 800x600, 1400x900, 2000x1500</p>
  
  <!--  Need IE11 support? https://scottjehl.github.io/picturefill/  -->
       <picture>
        <source srcset="https://dummyimage.com/2000x1500/000/fff" media="(min-width: 1400px)">
        <source srcset="https://dummyimage.com/1400x900/000/fff" media="(min-width: 768px)">
         <source srcset="https://dummyimage.com/800x600/000/fff" media="(min-width: 576px)">
        <img srcset="https://dummyimage.com/600x450/000/fff" alt="responsive image" class="img-fluid">
      </picture>
  
  
  
</div>
<!-- /.container -->
              
            
!

CSS

              
                body {margin:2rem;}

h3 {margin-top:3rem;}
h3, p {text-align: center;}
/*
####################################################
M E D I A  Q U E R I E S
####################################################
*/

/*
::::::::::::::::::::::::::::::::::::::::::::::::::::
Bootstrap 4 breakpoints
*/

/* 
Extra small devices (portrait phones, less than 544px) 
No media query since this is the default in Bootstrap because it is "mobile first"
*/


/* Small devices (landscape phones, 544px and up) */
@media (min-width: 544px) {  

}

/* Medium devices (tablets, 768px and up) 
The navbar toggle appears at this breakpoint */
@media (min-width: 768px) {  

}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) { 

}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {  
    
}



/*
::::::::::::::::::::::::::::::::::::::::::::::::::::
Custom media queries
*/

@media (max-width: 950px) { 

}

              
            
!

JS

              
                $(document).ready(function() {
 // executes when HTML-Document is loaded and DOM is ready
console.log("document is ready");
  
  
// document ready  
});


window.onload = function() {
 // executes when complete page is fully loaded, including all frames, objects and images
console.log("window is loaded");
  
  
// window load  
};



              
            
!
999px

Console