Skip to content

Instantly share code, notes, and snippets.

@ear1grey
Created August 8, 2012 11:21
Show Gist options
  • Save ear1grey/3294348 to your computer and use it in GitHub Desktop.
Save ear1grey/3294348 to your computer and use it in GitHub Desktop.
Shrink text of a particular class relative to how far scrolled a page is.
(function shrinky() {
var q = document.querySelectorAll(".shrink");
window.addEventListener(
"scroll",
function scroll () {
var i, z = 100-(Math.min(window.pageYOffset,100)/2);
for(i=0; i<q.length; i++) {
q[i].style.fontSize = z+"%";
}
}
);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment