欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS 打印界面的CSS居中代碼適用所有瀏覽器

 更新時(shí)間:2014年03月19日 15:55:53   作者:  
這篇文章主要介紹了JS 打印界面的CSS居中代碼,需要的朋友可以參考下
復(fù)制代碼 代碼如下:

function preview(oper) {
if (oper < 10) {
bdhtml = window.document.body.innerHTML;//獲取當(dāng)前頁的html代碼
sprnstr = "<!--startprint" + oper + "-->";//設(shè)置打印開始區(qū)域
eprnstr = "<!--endprint" + oper + "-->";//設(shè)置打印結(jié)束區(qū)域
prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr) + 18); //從開始代碼向后取html

prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//從結(jié)束代碼向前取html
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”>
<!–這里是要垂直居中的內(nèi)容–>
</div>
</div>
</div>

相關(guān)文章

最新評(píng)論