function preview(oper) {
if (oper < 10) {
bdhtml = window.document.body.innerHTML;//Gets the HTML code for the current page
sprnstr = "<!--startprint" + oper + "-->";//Set the print start area
eprnstr = "<!--endprint" + oper + "-->";//Set the end of print area
prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr) + 18); //Fetch the HTML back from the starting code
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//Fetch the HTML forward from the closing 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 vertically centered content >
</div>
</div>
</div>