The code copy is as follows:
function preview(oper) {
if (oper < 10) {
bdhtml = window.document.body.innerHTML;//Get the html code of the current page
sprnstr = "<!--startprint" + operator + "-->";//Set the printing start area
eprnstr = "<!--endprint" + operator + "-->";//Set the print end area
prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr) + 18); //Fetch html backward from the start code
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//Fetch html from the end code forward
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 what to center vertically>
</div>
</div>
</div>