作者sweetpotatoa (ㄏㄨㄢ。ㄕㄨˇ)
看板Web_Design
标题[问题] 置中问题
时间Thu Aug 9 16:32:39 2007
我在我的网页中有两个隐藏的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)