Skip to content
This repository was archived by the owner on Oct 4, 2018. It is now read-only.
/ Media-Query-Sync Public archive

Ⓜ️ A cross-browser solution for syncing Javascript functionality with CSS media queries

Notifications You must be signed in to change notification settings

bjankord/Media-Query-Sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Media-Query-Sync

A cross-browser solution for syncing Javascript functionality with CSS media queries

Read more about this technique here

How To

In your CSS file

  1. Add a font-family property to the head element with a value you wish to use for the name of your breakpoint
  2. Add an :after pseudo element with a content value the same as your font-family property to the body element
  3. Repeat steps 1 and 2 for each media queries you want to sync with JavaScript.

Remember, "The absence of support for @media queries is in fact the first @media query." - Bryan Rieger

In the mqSync function

  1. Set up conditions for your breakpoint variables from you CSS file
  2. Add the JavaScript you want executed in sync with your media queries inside the conditions you created

Demo

View Demo - with respond.js

View Demo - without respond.js

Thanks

Jeremy Keith, Chris Coyier, Emil Björklund

About

Ⓜ️ A cross-browser solution for syncing Javascript functionality with CSS media queries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published