Skip to content

Instantly share code, notes, and snippets.

@leemark
Created January 12, 2014 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemark/8387014 to your computer and use it in GitHub Desktop.
Save leemark/8387014 to your computer and use it in GitHub Desktop.
A Pen by Mark Lee.
<link href='http://fonts.googleapis.com/css?family=Codystar' rel='stylesheet' type='text/css'>
<h1>change color on scroll</h1>
var $doc = $(document),
$body = $('body'),
y = $doc.scrollTop(),
color1 = 0,
color2 = 0;
$doc.on('scroll', function(){
y = $doc.scrollTop();
color1 = y/30;
console.log(color1);
color2 = color1 + 180;
$body.css('background', 'hsla(' + color1 + ', 85%, 75%, 1)');
$body.find('h1').css('color', 'hsla(' + color2 + ', 95%, 40%, 1)');
});
body{
background: hsla(0, 85%, 75%, 1);
min-height: 3000vh;
}
h1{
font-family: 'Codystar', san-serif;
font-size: 12vw;
color: hsla(180, 95%, 40%, 1);
text-align: center;
position: fixed;
width: 100vw;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment