How to set div to center of the screen

<div id='div_id'>
Blah! Blah!
</div>

To set the div above to the center we can use next JQuery code.

jQuery.fn.center = function () {
    var w = $(window);
    this.css("position","fixed");
    this.css("top",w.height()/2-this.height()/2 + "px");
    this.css("left",w.width()/2-this.width()/2  + "px");
    return this;
}
$("#div_id").center();