jquery 设置div在浏览器的位置

<script type="text/javascript">
var offset = $("#health_alert").offset();
var alert_top = offset.top;
var window_height =$(window).height();
var alert_hight = $("#health_alert").outerHeight();
var alert_top = ( window_height - alert_hight )/ 2;
$("#health_alert").offset({ top: alert_top});
//alert(alert_hight);
</script>

http://api.jquery.com/height/

http://api.jquery.com/offset/

posted @ 2012-12-13 18:18  vincent_ds  Views(3480)  Comments(0Edit  收藏  举报