Team:UCLA/Template
From 2013.igem.org
(Difference between revisions)
Dewalgupta (Talk | contribs) |
Dewalgupta (Talk | contribs) |
||
Line 4: | Line 4: | ||
<link href='http://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'> | <link href='http://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'> | ||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> | <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> | ||
+ | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | ||
+ | <script> | ||
+ | $(document).ready(function(){ | ||
+ | |||
+ | |||
+ | var $window = $(window); //You forgot this line in the above example | ||
+ | |||
+ | $('section[data-type="background"]').each(function(){ | ||
+ | var $bgobj = $(this); // assigning the object | ||
+ | $(window).scroll(function() { | ||
+ | var yPos = -( ($(window).scrollTop() - $bgobj.offset().top) / $bgobj.data('speed')); | ||
+ | // Put together our final background position | ||
+ | var coords = '50% '+ yPos + 'px'; | ||
+ | // Move the background | ||
+ | $bgobj.css({ backgroundPosition: coords }); | ||
+ | }); | ||
+ | }); | ||
+ | }); | ||
+ | </script> | ||
</head> | </head> | ||
Revision as of 23:27, 25 September 2013