Created
January 12, 2013 18:19
-
-
Save erainey/4519730 to your computer and use it in GitHub Desktop.
JavaScript: jQuery UI Position Window Resize Demo
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>jQuery UI Position Window Resize Demo</title> | |
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css"> | |
<script src="http://code.jquery.com/jquery-1.8.3.js"></script> | |
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> | |
</head> | |
<body> | |
<div class="bgd"> | |
<div id="foo"></div> | |
</div> | |
</body> | |
</html> |
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
(function($){ | |
$("#foo").position({ | |
my: "center", | |
at: "center", | |
of: ".bgd" | |
}); | |
$(window).on('resize', function(e){ | |
$("#foo").position({ | |
my: "center", | |
at: "center", | |
of: ".bgd" | |
}); | |
}); | |
})(jQuery); |
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
.bgd {height:500px;width:100%;background:blue;} | |
#foo {width:25px;height:25px;background:white;position:absolute;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment