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

              
                <div class="content">
<h1>Creating true fluid web typography to improve our processes</h1>
<p class="lead">Responsive web design has been a must-have skill for front-end developers for many years now, but creating a truly fluid interface and giving users a seamless experience across any device still poses a lot of challenges for designers and developers alike.</p>
<blockquote>We, and seemingly everyone else, were stuck in the same old mindset: designers defined font sizes at every breakpoint for every element on the page and developers just had to make it happen.</blockquote>
<h2>A brief history</h2>
<p>Over the years, the web design community came up with various patterns for solving different layout or UX challenges on small screens and there are a plethora of available resources online to help you decide which route to take for your specific use-case. </p>
<p>The choice is never simple since you are constantly assessing the attractive, easy way (like using the hamburger icon to toggle navigation on small screens) and a more creative solution that’ll hopefully be better suited to the current problem-domain.</p>
  <h2>We found a solution that fits our needs</h2>
<p>Everything came through quite nicely and <strong>the final result exceeded all my expectations</strong>. The proof of concept I was looking for coalesced into as a very solid solution. So solid in fact that I was confident enough to use it in our latest WordPress theme, <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://pixelgrade.com/themes/restaurants/rosa2/" target="_blank">Rosa 2</a>.&nbsp;</p>
  <p>&hellip;</p>
  <div><a href="https://pixelgrade.com/blog/design/creating-true-fluid-web-typography/" class="button" target="_blank">Read more</a></div>
</div>
              
            
!

CSS

              
                @font-face {
  font-family: "Galano Classic";
  src: url("https://pxgcdn.com/fonts/galanoclassic/galano_classic_bold-webfont.woff2")
      format("woff2"),
    url("https://pxgcdn.com/fonts/galanoclassic/galano_classic_bold-webfont.woff")
      format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Galano Grotesque Alt";
  src: url("https://pxgcdn.com/fonts/galanogrotesquealt/galano_grotesque_alt-webfont.woff2")
      format("woff2"),
    url("https://pxgcdn.com/fonts/galanogrotesquealt/galano_grotesque_alt-webfont.woff")
      format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

$purple: #9660C6;

:root {
  // fluid typography settings
  --theme-font-size-breakpoint: 1440;
  --theme-font-size-minimum-value: 16;
  --theme-font-size-minimum-value-breakpoint: 320;
  --theme-font-size-slope-adjust: 0.6;
  --theme-addon-multiplier: 0;

  @media only screen and (min-width: 1440px) {
    --theme-font-size-slope-adjust: 0.2;
    --theme-addon-multiplier: 1;
  }

  // create a unit value that is relative to the viewport width to all font sizes
  --theme-addon-unit: calc(1vw - var(--theme-font-size-breakpoint) * 1px / 100);
  --theme-addon: calc(var(--theme-addon-unit) * var(--theme-addon-multiplier));
  
  --ms-ratio: 1.2;
  --ms-0: 16;
  
  @for $i from 1 through 8 {
    --ms-#{$i}: calc(var(--ms-#{$i - 1}) * var(--ms-ratio));    
  }

}

* {
  // x0 - viewport width at which font sizes should reach minimum value
  // y0 - minimum font size
  // x1 - viewport width at which we know the value for the font size
  // y1 - known font size
  --x0: var(--theme-font-size-minimum-value-breakpoint);
  --y0: var(--theme-font-size-minimum-value);
  --x1: var(--theme-font-size-breakpoint);
  
  // solving a first degree equation: y = ax + b
  --y1: var(--font-size);
  --y0-new: calc(var(--y1) - (var(--y1) - var(--y0)) * var(--theme-font-size-slope-adjust) );

  // calculate the slope and the remainder for the equation
  --a: calc((var(--y1) - var(--y0-new)) / (var(--x1) - var(--x0)));
  --b: calc(var(--y0-new) - var(--a) * var(--x0));

  // x2 - viewport width at a given time
  // y2 - font size value we need to find out
  --y2: calc(var(--a) * 100vw + var(--b) * 1px);
  --final-font-size: calc(var(--y2) + var(--theme-addon));
}

body {
  --font-size: var(--ms-1);
  font-size: var(--final-font-size);
  line-height: 1.5;
  font-family: Galano Grotesque Alt, sans-serif;
  padding: 2em 2em 4em;  
}

p {
  line-height: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6,
blockquote {
  font-family: Galano Classic, sans-serif;
}

h1 {
  --font-size: var(--ms-8);
  font-size: var(--final-font-size);
  line-height: 1.2;
}

h2 {
  --font-size: var(--ms-5);
  font-size: var(--final-font-size);
}

.lead,
blockquote {
  --font-size: var(--ms-2);
  font-size: var(--final-font-size);
}

.content {
  max-width: 40em;
  margin-left: auto;
  margin-right: auto;

  > * {
    margin-top: 2rem;
  }
}

a {
  color: $purple;
}

.button {
  position: relative;
  display: inline-block;
  padding: 0.75em 1.25em;
  border: 0;
  text-decoration: none;
  color: #ffffff;
  background-color: $purple;
  border-radius: 4px;

  transition: all 0.2s cubic-bezier(0, 0, 0.58, 1);
  transition-property: transform, background, background-color, color, box-shadow;
  cursor: pointer;
  
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -moz-osx-font-smoothing: grayscale;

  &:hover {
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.7);
  }

  &:active,
  &:focus {
    transform: scale(1.02) translateY(1px);
    transition-duration: 0.1s;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console