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.

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

              
                <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pharetra consequat ipsum, et ullamcorper massa commodo ac. Nullam nulla sem, porttitor ac dui aliquam, varius facilisis massa. Sed risus ligula, vulputate eu semper sit amet, auctor a dolor. Donec mi ipsum, rhoncus sed tellus non, dignissim hendrerit orci. Pellentesque pulvinar, tellus nec maximus egestas, metus enim volutpat tortor, euismod mattis velit libero nec elit. Nulla nec velit rhoncus, malesuada nisi sit amet, eleifend quam. Suspendisse pretium arcu lacus, quis sodales lacus sodales eu.
</p>
<div class="scale__container--js">
    <h1 class="scale--js">I'm full width</h1>
</div>
<p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pharetra consequat ipsum, et ullamcorper massa commodo ac. Nullam nulla sem, porttitor ac dui aliquam, varius facilisis massa. Sed risus ligula, vulputate eu semper sit amet, auctor a dolor. Donec mi ipsum, rhoncus sed tellus non, dignissim hendrerit orci. Pellentesque pulvinar, tellus nec maximus egestas, metus enim volutpat tortor, euismod mattis velit libero nec elit. Nulla nec velit rhoncus, malesuada nisi sit amet, eleifend quam. Suspendisse pretium arcu lacus, quis sodales lacus sodales eu.
</p>
<div class="container">
    <div class="scale__container--js">
        <h2 class="scale--js">I'm full width too!</h2>
    </div>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pharetra consequat ipsum, et ullamcorper massa commodo ac. Nullam nu
    </p>
</div>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #333;
  color:#fff;
  font-family: 'Open Sans Condensed'
}

p {
  line-height: 20px;
}

.scale__container--js {
  text-align: center;
}
.scale--js {
  display: inline-block;
  transform-origin: 50% 0;
  -webkit-font-smoothing: antialiased;
  transform: translate3d( 0, 0, 0);
}
.container {
  margin: 30px 0;
  max-width: 500px;
  background: tomato;
  padding:30px;
}
              
            
!

JS

              
                function scaleHeader() {
  var scalable = document.querySelectorAll('.scale--js');
  var margin = 10;
  for (var i = 0; i < scalable.length; i++) {
    var scalableContainer = scalable[i].parentNode;
    scalable[i].style.transform = 'scale(1)';
    var scalableContainerWidth = scalableContainer.offsetWidth - margin;
    var scalableWidth = scalable[i].offsetWidth;
    scalable[i].style.transform = 'scale(' + scalableContainerWidth / scalableWidth + ')';
    scalableContainer.style.height = scalable[i].getBoundingClientRect().height + 'px';
  }
} 


// Debounce by David Walsch
// https://davidwalsh.name/javascript-debounce-function

function debounce(func, wait, immediate) {
	var timeout;
	return function() {
		var context = this, args = arguments;
		var later = function() {
			timeout = null;
			if (!immediate) func.apply(context, args);
		};
		var callNow = immediate && !timeout;
		clearTimeout(timeout);
		timeout = setTimeout(later, wait);
		if (callNow) func.apply(context, args);
	};
};

var myScaleFunction = debounce(function() {
	scaleHeader();
}, 250);

myScaleFunction();

window.addEventListener('resize', myScaleFunction);
              
            
!
999px

Console