Created
December 7, 2012 17:38
-
-
Save ElijahGartin/4234968 to your computer and use it in GitHub Desktop.
Fixed Div jQuery Scrolling Script
This file contains 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Untitled Document</title> | |
<link href="style.css" rel="stylesheet" type="text/css" media="all" /> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script> | |
<script> | |
//<![CDATA[ | |
$(window).load(function(){ | |
var $sdiv = $("#mydiv"); | |
$(window).scroll(function() { | |
$sdiv.stop().animate({ | |
"marginTop": ($(window).scrollTop() + 50) + "px" | |
}, "slow"); | |
}); | |
});//]]> | |
</script> | |
</head> | |
<body> | |
<div id="mydiv"></div> | |
</body> | |
</html> |
This file contains 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
/* CSS definition file containing sitestyle stylesheets */ | |
/******************************************** | |
CSS Styles | |
Author : Elijah Gartin | |
Date: 06Aug2012 | |
Updated: 18Sept2012 | |
********************************************/ | |
/*---*---*---*---*---*---*---*---*---*---*--- | |
Organization Layout | |
*---*---*---*---*---*---*---*---*---*---*---*/ | |
body { | |
height: 2000px; | |
} | |
#mydiv{ | |
background: red; | |
width: 100px; | |
height: 100px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment