Copy Code code as follows:
Function Preview (oper) {
if (Oper < 10) {
bdhtml = window.document.body.innerhtml;//Get the HTML code for the current page
Sprnstr = "<!--startprint" + oper + "-->";//Set Print start area
Eprnstr = "<!--endprint" + oper + "-->";//Set Print End area
prnhtml = bdhtml.substring (Bdhtml.indexof (SPRNSTR) + 18); Fetching HTML backwards from the start code
prnhtml = prnhtml.substring (0, Prnhtml.indexof (eprnstr));//forward HTML from end code
Window.document.body.innerHTML = prnhtml;
Window.print ();
Window.document.body.innerHTML = bdhtml;
} else {
Window.print ();
}
}
#outer {
display:table;
height:400px;
#position: relative;
Overflow:hidden;
}
#middle {
Display:table-cell;
Vertical-align:middle;
#position: absolute;
#top: 50%;
}
#inner {
#position: relative;
#top:-50%;
}
<div id= "outer" >
<div id= "Middle" >
<div id= "inner" >
<!– here is the content to be centered vertically –>
</div>
</div>
</div>