/ Published in: jQuery
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
Markup:
<script src="http://jquery-ui.googlecode.com/svn/trunk/jquery-1.4.2.js"></script>
<script src="http://jquery-ui.googlecode.com/svn/trunk/ui/jquery.ui.position.js"></script>
<div id="foo">
My centered foo box
</div>
<script>
$('#foo')
.css({ top: 0, left: 0 })
.position({
my: 'center center',
at: 'center center',
collision: 'fit',
of: window,
using: function(pos) {
var topOffset = $(this).css(pos).offset().top;
if (topOffset < 0) {
$(this).css('top', pos.top - topOffset);
}
}
});
</script>
URL: hire.chrisjlee.net
Comments
 Subscribe to comments
                    Subscribe to comments
                
                