[問題] 置中問題

看板Web_Design作者 (ㄏㄨㄢ。ㄕㄨˇ)時間19年前 (2007/08/09 16:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
我在我的網頁中有兩個隱藏的div tag handlePage,full 我想在使用者按下某個按鍵後 就由ajax call去將server的表格抓下來填handlePage的值 然後full就依照視窗大小填滿然後半透明化 但是出現了兩個問題 1.full不能夠"剛好"填滿整個畫面(ie,ff都不行) 大小我嘗試過兩種計算法 document.body.clientHeight,document.body.clientWidth; screen.width,screen.height; 就是算不出正確的size 2.我想讓handlePage完全置中(依照傳來的表格) 所以想用(page size/2-table size/2)來當該div的top,left位置 達到置中效果(不管瀏覽器不管視窗大小,一定要置中) 可是好像因為server端傳過來的table size無法得知 沒有辦法算出大小(就算有好像也都沒辦法置中) 請問有沒有辦法解決 小弟不才,請大家幫忙,謝謝^^ ===以下為兩tag的style(參考某網友的置中範例) div#full{ background-color: #000000; display: none; position: absolute; filter: Alpha(Opacity=80); opacity: 0.8; left: 1px; top: 1px; width: auto; height: auto; right: 1px; bottom: 1px; margin: 1px; padding: 5px; } #handlepage { position: absolute; display: none; background-color: #FFFFFF; border: 1px solid #CCCCCC; font-size: 16px; font-weight: bolder; color: #FF0000; margin-top:20%; /*防止多餘的table白底出現*/ margin-left:30%; margin-right:25%; text-align:center; } ===設定size的script x = document.body.clientHeight; y = document.body.clientWidth; $("full").style.width = screen.width; $("full").style.height = screen.height; $("handlepage").style.top = x/2 - screen.height/2+"px"; $("handlepage").style.left = y/2 - screen.width/2+"px"; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.87.139.83 ※ 編輯: sweetpotatoa 來自: 219.87.139.83 (08/09 16:35)
文章代碼(AID): #16kj4gZJ (Web_Design)
文章代碼(AID): #16kj4gZJ (Web_Design)