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/

原文地址:https://www.cnblogs.com/vincent_ds/p/2816854.html