Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Responsive Web Typography Crash Course

Here's the quickest way to make your web typography responsive... without using any media queries! WHAT?!?

Please watch the video.

For quick copy paste, take the following SCSS code and drop it into http://sassmeister.com

//credit: PK (almostinevitable.com) 
//this one is the simplified version
@mixin awesome-pixel-sizes($desktop-size, $desktop-px, $mobile-size, $mobile-px) {
  ///desktop & mobile
  //$desktop-size: 1440;
  //$mobile-size: 780;
  $rem: 16;

  ///calcs
  $delta: ($desktop-px - $mobile-px) / ($desktop-size - $mobile-size); ///slope
  $delta-rounded: round($delta * 1000) / 1000; ///slope rounded.. round slope
  $deltavw: ($delta-rounded * 100);

  $intercept: ($mobile-px - ($delta-rounded * $mobile-size)); ///y intercept

  ///pixel based
  $calc-vw: (($desktop-px - $rem) * 100) / $desktop-size;
  $calc-01: (($calc-vw * $mobile-size) * .01) + $rem;
  $calc-01-rounded: round($calc-01 * 10000) / 10000;
  $final-rem: ($mobile-px / $calc-01-rounded);
  $final-rem-rounded: round($final-rem * 10000) / 10000;

  ///results
  ///for compatibility
  font-size: calc(#{$calc-vw}vw + #{$final-rem-rounded}rem);

  ////for clamps 
  @if $intercept < 0 {
    $thecalc: ($intercept * -1);
    font-size: clamp(#{$mobile-px}px, calc(#{$deltavw}vw - #{$thecalc}px), #{$desktop-px}px);
  } @else {
    $thecalc: $intercept;
    font-size: clamp(#{$mobile-px}px, calc(#{$deltavw}vw + #{$thecalc}px), #{$desktop-px}px);
  }
}

.single {
  h1 {
    line-height: 1.2;
    letter-spacing: .05em;
    margin: 2em 0 1em 0;
    @include awesome-pixel-sizes(1280, 54, 650, 24);
  }
  h2 {

  }
  h3 {

  }
  h4 {

  }
  h5 {

  }
  h6 {

  }
  p, 
  li {

  }
}

Here are the parent selectors you could use depending on your site builder of choice.

WIX 
	#site-root

Webflow 
	body.body

Squarespace	
	#siteWrapper
	#page 

Shopify - Debut
	body.template-index

Divi 
	#page-container 
	#et-boc

Elementor 
	body
	#main 

Beaver Builder 
	.fl-page
	#fl-main-content 

Oxygen
	body 
	#inner_content-11-1 (Change the numbers to work on your site)

Genesis 
	#genesis-content
	.site-content

PS. Duda didn’t even load the templates for me to inspect, so… and that was even AFTER I went to the .com and realized that it’s not the page building service. .. what..? I don’t even remember what the TLD was. It’s THAT bad. So I didn’t include Duda in the list. Sorry, you’re worse than WIX and that’s saying something.

Please note: for Squarespace users

Squarespace uses LESS in its custom CSS entry field. So you can’t just drop in

calc(2.3vw + 1.2rem)

the numbers will calculate. whoops. So you’ll have to escape it into a string with a ~”” like this

calc(~"2.3vw + 1.2rem")

and it should work.

Impressed with the method? I have a lot more of these kinds of goodies in my SASS folder.

If you’re interested in SASS, you’re in luck!

Check this out!

Also, if you’re interested in getting started in CSS have a look at this.

There’s also a CSS package.

Lastly, if you want to go full-blown custom structure with your own custom theme, then have a look at this.

Default image
PK

Hi, I'm a front-end WordPress developer, and UI/UX designer living in Australia, and I made this website to share thoughts and tips about web design and everything related to it. If you want to work with me come check out my web development agency.

Articles: 82

Leave a Reply

Your email address will not be published.