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

              
                <p id="text" contenteditable>Little fluffy jello</p>
              
            
!

CSS

              
                @font-face {
	font-family: "Source Sans Variable";
	src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/209981/SourceSansVariable-Roman.ttf");
}

html {
	height: 100%;
}

body {
	height: 100%;
  background: linear-gradient(to top, #7f7fd5, #86a8e7, #91eae4);
}

p {
	--weight: 200;
	font-family: "Source Sans Variable";
	font-variation-settings: 'wght' var(--weight);
	font-size: 18vw;
	color: white;

	// Positioning
	position: absolute;
	top: 50%;
	transform: translate(0, -50%);
	margin: 0;
	width: 100%;
	text-align: center;
}


              
            
!

JS

              
                
// JS is to make the text editable, not required for the effect. Thanks for the suggestion @chriscoyier! 
var p = document.querySelector("p");

p.addEventListener("input", function() {
    this.setAttribute("data-heading", this.innerText);
});

function variableResize() {
	
	// Minimum & Maximum font weight
	const minFontWeight = 200;
	const maxFontWeight = 900;
	
	// Minimum and Maximum viewport size
	const maxWindowSize = 1440;
	const minWindowSize = 320;
	
	// Get current viewport size
	const windowWidth = window.innerWidth
	
	//Scale within a range
	const percent = (windowWidth - minWindowSize) / (maxWindowSize - minWindowSize);
	const fontWeightScale = percent * (minFontWeight - maxFontWeight) + maxFontWeight;
      
	// Get the new font weight
	const newWeight = windowWidth > maxWindowSize
	   ? minFontWeight 
       : windowWidth < minWindowSize 
   			? maxFontWeight 
   			: fontWeightScale;
	   
		// Set my CSS Custom Property for weight to update.
     	p.style.setProperty("--weight", newWeight);
}

window.addEventListener("resize", variableResize);



              
            
!
999px

Console