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 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="master-container">
  <h1>Scaling Text Size</h1>
  <p>We all know and ideal measure (line length) is round about 65 characters, with differing opinions as to an acceptable range around that. Of course, maintaining this ideal on the web is a difficult task. Developers often turn to the EM/REM to knotch up and down a base font size as widths adjust, but this is hardly an ideal case. I've made a mixin to scale text exactly between two sizes for a particular range of screen sizes.</p>
  <p><strong>The following text will scale smoothly from 11px to 38px as the browser window changes between 400px and 1280px keeping nearly the same measure the entire time.</strong></p>
  <div class="wrapper">
    <p>Lorem ipsum dolor sit amet, ad stet propriae vix, volutpat assentior ex qui. Qui ad dolorem atomorum praesent, deserunt eloquentiam neglegentur mei ut. Pri ullum oratio in, mea ad tritani consequat disputando. Eu minim sonet signiferumque sit.</p>
    <p>At sed dolorem civibus, quis eius perfecto ea qui. Qui et malorum eruditi. Lorem regione rationibus ex eum, mei assum soleat verear ut. Prompta accusata explicari est ea. Ut tale modus idque vim, vivendum gubergren cum no.</p>
    <p>Liber paulo in eam, ius ex ocurreret mediocritatem. Pri appetere tincidunt cotidieque ad, ex sed ocurreret explicari. Ei est fabulas accumsan phaedrum, duo harum possit ad. Assum dicit delectus ius ad, omnesque postulant repudiare cum cu, libris officiis voluptaria ne ius. Te duo integre albucius perpetua. Pro atqui suavitate gloriatur eu, indoctum reformidans ea ius.</p>
    <p>Atomorum liberavisse vix an, in autem fastidii mea, vel case suavitate ad. At quo munere discere, agam inimicus philosophia an sed. Solum epicurei torquatos no vix, cu vel delectus consequat, mei amet facer iuvaret te. Has everti alterum convenire ut, sint graece in sed. Vix no discere accusata.</p>
    <p>Sea id esse vide consul, veritus copiosae inciderint sed at. Ad nec regione posidonium. At sed ridens volumus constituam. Ea pri reque mundi dicam. Virtute praesent pertinacia sea cu, fabellas pericula at sed, ad iudico scaevola his.</p>
  </div>
</div>
              
            
!

CSS

              
                $text-color: #475156;
$border-color: #b1b7b9;

@mixin responsive-type($min-size, $max-size, $min-width, $max-width) {
  $slope: ($max-size - $min-size) / ($max-width - $min-width);
  font-size: calc((100vw - #{$min-width}) * #{$slope} + #{$min-size});
  
  @media (max-width: $min-width) {
    font-size: $min-size;
  }
  @media (min-width: $max-width) {
    font-size: $max-size;
  }
}

.wrapper {
  @include responsive-type(11px, 38px, 400px, 1280px);
}

.good {
  background-color: rgba(180,0,0,.15);
}
.better {
  background-color: rgba(180,0,0,.25);
}
.best {
  background-color: rgba(180,0,0,1);
}

/*****
 ***** Page Styles */
* {
  box-sizing: border-box;
}
body {
  font-family: helvetica neue, helvetica, sans-serif;
  color: $text-color;
}
.master-container {
  width: 93.75%;
  padding: 1em 0;
  margin: 0 auto;
  min-width: 150px;
  max-width: 1800px;
}

.wrapper {
  position: relative;
  padding-right: 0.5em;
  border-right: 1px solid $border-color;
}

              
            
!

JS

              
                $('.wrapper p').each(function() {
  var $this = $(this);
  var text = $this.text();
  var newText = text.slice(0,45)
                + '<span class="good">' + text.slice(45,55)
                  + '<span class="better">' + text.slice(55,65)
                    + '<span class="best">' + text.slice(65,66) + '</span>'
                  + text.slice(66,75) + '</span>'
                + text.slice(75,85) + '</span>'
              + text.slice(85);
  $this.html(newText);
});
              
            
!
999px

Console