Skip to content

Instantly share code, notes, and snippets.

@erainey
Created January 12, 2013 18:19
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 erainey/4519730 to your computer and use it in GitHub Desktop.
Save erainey/4519730 to your computer and use it in GitHub Desktop.
JavaScript: jQuery UI Position Window Resize Demo
<!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>
(function($){
$("#foo").position({
my: "center",
at: "center",
of: ".bgd"
});
$(window).on('resize', function(e){
$("#foo").position({
my: "center",
at: "center",
of: ".bgd"
});
});
})(jQuery);
.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