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

              
                <article>
		<header>
			<h1>
				Noframe.js 
			</h1>
			<p>This page is a demo of a <a href="https://github.com/yowainwright/reframe.js">Noframe.js</a> - a very basic lightweight plugin that makes iframes or embedded content responsive.</p>
      <p>More deeply, this means that it makes elements scale at a fixed ratio.</p>
		</header>
		<div>
			<iframe width="560" height="315" src="https://www.youtube.com/embed/6FQsIfE7sZM" frameborder="0" allowfullscreen></iframe>
      </div>
			<p>This is an <code>iframe</code> that contains a video.</p>
		<footer>
			<p>~Thanks</p>
		</footer>
	</article>
              
            
!

CSS

              
                figure,p{margin:1rem 0}figcaption{margin:.5rem 0;text-align:center}article{margin:1rem;width:100%;}@media screen and (min-width:768px){article{margin:1rem auto;max-width:700px}}footer p,h1{text-align:center}footer,h1{margin:2rem auto}
              
            
!

JS

              
                /**
  reframe.js - Reframe.js: responsive iframes for embedded content
  @version v4.0.0
  @link https://github.com/yowainwright/reframe.ts#readme
  @author Jeff Wainwright <yowainwright@gmail.com> (http://jeffry.in)
  @license MIT
**/
(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define(factory) :
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.noframe = factory());
})(this, (function () { 'use strict';

  /* noframe.js () 🖼
    -------------
    takes 2 arguments:
    => target: targeted <element>
    => container: optional targeted <parent> of targeted <element>
    -------------
    defines the height/width ratio of the targeted <element>
    based on the targeted <parent> width
  */
  function noframe(target, container) {
      var frames = typeof target === 'string' ? document.querySelectorAll(target) : target;
      if (!('length' in frames))
          frames = [frames];
      for (var i = 0; i < frames.length; i += 1) {
          var frame = frames[i];
          var isContainerElement = typeof container !== 'undefined' && document.querySelector(container);
          var parent_1 = isContainerElement ? document.querySelector(container) : frame.parentElement;
          var h = frame.offsetHeight;
          var w = frame.offsetWidth;
          var styles = frame.style;
          // => If a targeted <container> element is defined
          if (isContainerElement) {
              // gets/sets the height/width ratio
              var maxW = window.getComputedStyle(parent_1, null).getPropertyValue('max-width');
              styles.width = '100%';
              // calc is needed here b/c the maxW measurement type is unknown
              styles.maxHeight = "calc(".concat(maxW, " * ").concat(h, " / ").concat(w, ")");
          }
          else {
              // gets/sets the height/width ratio
              // => if a targeted <element> closest parent <element> is NOT defined
              styles.display = 'block';
              styles.marginLeft = 'auto';
              styles.marginRight = 'auto';
              var fullW = w > parent_1.offsetWidth ? parent_1.offsetWidth : w;
              var maxH = w > parent_1.offsetWidth ? (fullW * h) / w : w * (h / w);
              // if targeted <element> width is > than it's parent <element>
              // => set the targeted <element> maxheight/fullwidth to it's parent <element>
              styles.maxHeight = "".concat(maxH, "px");
              styles.width = "".concat(fullW, "px");
          }
          // set a calculated height of the targeted <element>
          var cssHeight = (100 * h) / w; // eslint-disable-line no-mixed-operators
          styles.height = "".concat(cssHeight, "vw");
          styles.maxWidth = '100%';
      }
  }

  return noframe;

}));

noframe('iframe');
              
            
!
999px

Console