JS Print Interface CSS Center code for all browser _javascript tips

Source: Internet
Author: User
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>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.