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

              
                <article class="fluidtype">
  <h1>Some fluid modular scale h1</h1>
  <h2>Some fluid modular scale h2</h2>
  <h3>Some fluid modular scale h3</h3>
  <h4>Some fluid modular scale h4</h4>
  <h5>Some fluid modular scale h5</h5>
  <h6>Some fluid modular scale h6</h6>
  <p><strong>Blue lines:</strong> using a modular scale more suitable for smaller screens. Text is not scaling.<br><strong>Pink linkes:</strong> Using a second modular scale more suitable for larger screens. Text is scaling.<br><strong>Green lines:</strong> Text is no longer scaline, using the defined max font values and the second modular scale. Screen is larger than 105em or 1680px. <br><br>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
</article>
              
            
!

CSS

              
                :root{
    --modular1: 1.125;
    --modular2: 1.414;

    --startwidth: 30;
    --endwidth:105;

    //need these numbers for h6 and p without units for calc.
    --base-min: 1;
    --base-max:1.25;

    
    --h1-responsive: calc(var(--h1-size) + ((var(--modular2) * var(--modular2) * var(--modular2) * var(--modular2) * var(--modular2)) - (var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
    --h2-responsive:calc(var(--h2-size) + ((var(--modular2) * var(--modular2) * var(--modular2) * var(--modular2)) - (var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
    --h3-responsive:calc(var(--h3-size) + ((var(--modular2) * var(--modular2) * var(--modular2)) - (var(--modular1) * var(--modular1) * var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
    --h4-responsive:calc(var(--h4-size) + ((var(--modular2) * var(--modular2)) - (var(--modular1) * var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));    
    --h5-responsive:calc(var(--h5-size) + ((var(--modular2)) - (var(--modular1))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
    --h6-responsive:calc(var(--h6-size) + ((var(--base-max)) - (var(--base-min))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));
    --p-responsive:calc(var(--p-size) + ((var(--base-max)) - (var(--base-min))) * ((100vw - (var(--startwidth) * 1em)) / (var(--endwidth) - var(--startwidth))));

    //Initially I wanted to use an expression like this, and just change the font-min and font-max for each header:
    //--fontsize-responsive:calc(var(--font-min) * 1rem + ((var(--font-max)) - (var(--font-min))) * ((100vw - (var(--startwidth) * 1rem)) / (var(--endwidth) - var(--startwidth))));
    //But I needed a unit to use calc, and font-min and font-max could not be calculated without a unit. For the above to work, they needed to be unitless. Perhaps there is a way around this?

    --h1-size: calc(var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * 1em);

    --h2-size: calc(var(--modular1) * var(--modular1) * var(--modular1) * var(--modular1) * 1em);

    --h3-size: calc(var(--modular1) * var(--modular1) * var(--modular1) * 1em);

    --h4-size: calc(var(--modular1) * var(--modular1) * 1em);

    --h5-size: calc(var(--modular1) * 1em);

    --h6-size:calc(var(--base-min) * 1em);

    --p-size:calc(var(--base-min) * 1em);
}

//Striped background
body{
  font-family:/*ios*/ "HelveticaNeue", /*android*/ "Roboto", /*fallbacks*/ Arial, Verdana, "Trebuchet MS", sans-serif;
  font-weight: 400;

  //The first rgba color sets the line color
  background: linear-gradient(0, #d7ded8 1px, rgba(0, 0, 0, 0) 1px),
              linear-gradient(0, #9ec6f5 1px, rgba(0, 0, 0, 0) 1px);
  //The second px value sets the height between lines
  background-size: 1px 1.5em, 1px 0.75em;
}

.fluidtype{
  max-width:105em;
  margin: 0 auto;
  display:block;
  padding:0 1.5em;

  h1,h2,h3,h4,h5{
    padding: 0;
  }

  h1{ 
    font-size: var(--h1-size);
    line-height: 1.45669;//42px;
    margin:(12/28.8325)+em 0;
  }

  h2{ 
    font-size: var(--h2-size);
    line-height: 1.5217196212; //39
    margin:(10.5/25.6289)+em 0;
  }
    
  h3{ 
    font-size: var(--h3-size);
    line-height: 1.5802469;
    margin:(12/22.7813)+em 0;
  }
	
  h4{ 
    font-size: var(--h4-size);
    line-height: 1.629629629629; //33
    margin:(9/20.25)+em 0;
  }

  h5{ 
    font-size: var(--h5-size);
    line-height: 1.66666667; //30
    margin:(6/18)+em 0;
  }

  h6{
    font-size:var(--h6-size);
    line-height:1.5; // 1.6;
    margin:0 auto; //12px        
  }

    p{ 
		line-height:1.5;
    margin: 0.75em auto;
    font-size:var(--p-size);
	}

	h1 + p, h2 + p, h3 + p, h4 + p, h5 + p, h6 + p{
		margin-top: 0;
    }
}//fluidtype


@media only screen and (min-width: 30em) {
  .fluidtype h1, .fluidtype h2, .fluidtype h3, .fluidtype h4, .fluidtype h5{
    //expression for responsive margins
    --margin-responsive: calc((var(--margin-min, 1) * 1rem) + (var(--margin-max, 1.125) - var(--margin-min, 1)) * ((100vw - (var(--startwidth) * 1rem)) / (var(--endwidth) - var(--startwidth))));
    margin:var(--margin-responsive) auto;

    //expression for responsive line-heights
    --lineheight-responsive:calc((var(--lineheight-min) * 1rem) + (var(--lineheight-max) - var(--lineheight-min)) * ((100vw - (var(--startwidth) * 1rem)) / (var(--endwidth) - var(--startwidth))));
    line-height: var(--lineheight-responsive);
  }

  .fluidtype h1{
    --margin-min:0.75; //12
    --margin-max: 1.875; //30;
    --lineheight-min:2.625; //42
    --lineheight-max:7.03125;//112.5
    font-size:var(--h1-responsive);
  }

  .fluidtype h2{
    font-size:var(--h2-responsive);                
    --margin-min:0.65625; //10.5
    --margin-max:1.875; //30
    --lineheight-min:2.4375; //39
    --lineheight-max:5.625; //90
  }

  .fluidtype h3{
    font-size:var(--h3-responsive);
    --margin-min:0.75; //12
    --margin-max:1.875; // 30
    --lineheight-min:2.25;  //36
    --lineheight-max:4.21875; //67.5
  }

  .fluidtype h4{
    font-size:var(--h4-responsive);
    --margin-min:0.5625;//9
    --margin-max:0.9375;// 15
    --lineheight-min: 2.0625;//33px
    --lineheight-max: 3.28125;//52.5
  }

  .fluidtype h5{
    font-size:var(--h5-responsive);
    --margin-min:0.375;//6
    --margin-max:0.9375;// 15
    --lineheight-min:1.875;
    --lineheight-max: 2.34375;
  }

  .fluidtype h6{
    font-size: var(--h6-responsive);
  }        

  .fluidtype p{
    font-size: var(--p-responsive);
  }
  
  body{
    background: linear-gradient(0, #d7ded8 1px, rgba(0, 0, 0, 0) 1px),
                linear-gradient(0, #ffc8fd 1px, rgba(0, 0, 0, 0) 1px);
    //Scaling the background size as the screen size changes. 1.5 is for the base line-height, and it's multiplied with the calculation for p font-size when the font-size is responsive
    background-size:1px calc(1.5 * (1rem + 0.25 * ((100vw - 30rem) / 75))), 1px calc(0.75 * (1rem + 0.25 * ((100vw - 30rem) / 75)));
  }
}

//CHROME ONLY: There is a bug or possibly rounding error that makes the lines jump. This adjust for this.
@media only screen and (min-width:42.5em) { //680
  body{
    background-size:1px calc((1.5 * (1rem + 0.25 * ((100vw - 30rem) / 75))) - 1px), 1px calc(0.75 * (1rem + 0.25 * ((100vw - 30rem) / 75)));
  }
  
   p{
    column-count:2;
  }
}

@media only screen and (min-width:55em) { //880
  body{
    background-size:1px calc(1.5 * (1rem + 0.25 * ((100vw - 30rem) / 75))), 1px calc(0.75 * (1rem + 0.25 * ((100vw - 30rem) / 75)));
  }
}

@media only screen and (min-width:67.5em) { //1080
  body{
    background-size:1px calc((1.5 * (1rem + 0.25 * ((100vw - 30rem) / 75))) - 1px), 1px calc(0.75 * (1rem + 0.25 * ((100vw - 30rem) / 75)));
  }
}

@media only screen and (min-width:80em) { //1280
  body{
    background-size:1px calc(1.5 * (1rem + 0.25 * ((100vw - 30rem) / 75))), 1px calc(0.75 * (1rem + 0.25 * ((100vw - 30rem) / 75)));
  }
  
  p{
    column-count:3;
  }
}

@media only screen and (min-width:92.5em) { //1480
  body{
    background-size:1px calc((1.5 * (1rem + 0.25 * ((100vw - 30rem) / 75))) - 1px), 1px calc(0.75 * (1rem + 0.25 * ((100vw - 30rem) / 75)));
  }
}

@media only screen and (min-width: 105em) {
  :root{
    //changing scales and base
    --modular1: var(--modular2);
    --base-min: var(--base-max);
  }

  .fluidtype h1{
    font-size: var(--h1-size);
    line-height: (112.5/90.4413);
    margin: 0.331706864em auto;//30px
  }

  .fluidtype h2{
    font-size: var(--h2-size);
    line-height:(90/63.9613);
    margin:0.469033618766em auto;
  }
  .fluidtype h3{
    font-size: var(--h3-size);
    line-height:(67.5/45.2342);
    margin:(30/45.2342)+em auto;
  }
  .fluidtype h4{
    font-size: var(--h4-size);
    line-height:(52.5/31.9903);
    margin:(15/31.9903)+em auto;
  }
  .fluidtype h5{
    font-size: var(--h5-size);
    line-height:(37.5/22.624);
    margin:(15/22.624)+em auto;
  }

  .fluidtype h6{
    font-size: var(--h6-size);
  }

  .fluidtype p{
    font-size: var(--p-size);
  }
  
  body{
    background: linear-gradient(0, #d7ded8 1px, rgba(0, 0, 0, 0) 1px),
                linear-gradient(0, #97d09e 1px, rgba(0, 0, 0, 0) 1px);
    //Adjusting for max-font-size for p
    background-size:1px 1.875em, 1px 0.9375em;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console