Created
January 12, 2014 16:38
-
-
Save leemark/8387014 to your computer and use it in GitHub Desktop.
A Pen by Mark Lee.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href='http://fonts.googleapis.com/css?family=Codystar' rel='stylesheet' type='text/css'> | |
<h1>change color on scroll</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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