垂直置中層 js操作css

來源:互聯網
上載者:User
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">//這個一定要加 因為ie8  xhtml4.0不支援fixed  如果第一個層高度超過瀏覽器高度 也就是有捲軸  imgdiv是不隨捲軸滾動而滾動,它一直都在那裡<body id="gn" ></body><script language="javascript"> function $$(titleName) {    return document.createElement(titleName); }function $(e){    return document.getElementById(e);}var lodingBox = $$("div");lodingBox.style.position="fixed";lodingBox.style.width=screen.width+"px";        lodingBox.style.height=screen.height+"px";        lodingBox.style.backgroundColor="#cccccc";        lodingBox.id="lodingBox";var imgdiv=$$("div");var imgdiv_width="300";var imgdiv_height="100";var imfdiv_left=screen.width-screen.width/2-imgdiv_width/2;//為什麼要減去100px//我也不知道為什麼 因為這樣算出來上邊高底下低所以我就再減去100pxvar imfdiv_height=screen.height-screen.height/2-imgdiv_height/2-100;imgdiv.style.position="fixed";imgdiv.style.left=imfdiv_left+"px";imgdiv.style.top=imfdiv_height+"px";imgdiv.style.width=imgdiv_width+"px";imgdiv.style.height=imgdiv_height+"px";        imgdiv.style.backgroundColor="red";        imgdiv.id="imgdiv";        var lodingImg=$$("img");        lodingImg.src="loadingmin.gif";        var lodingText=$$("span");        lodingText.innerHTML="正在存入資料,請稍候....";                imgdiv.appendChild(lodingImg);        imgdiv.appendChild(lodingText);        $("gn").appendChild(lodingBox);       $("gn").appendChild(imgdiv); var temp=1;         zheli(10);       // $("lodingBox").style.display="none"; //$("imgdiv").style.display="none";function zheli(n){if(n==1){return temp;}temp=temp*n;//document.write(temp+"<br />");//遞迴zheli(n-1);}</script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.