怎么设置屏幕宽度???

fgcsh 2002-05-15 10:02:45
<div id="login" style="LEFT:18; POSITION:absolute; TOP: 222; width:231; height:165">
在style中的left值替换成动态值?(根据屏幕宽度来设置)
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fgcsh 2002-05-15
  • 打赏
  • 举报
回复
不行呀
孟子E章 2002-05-15
  • 打赏
  • 举报
回复
<HTML>
<script>
function divcenter(){
document.all.mxh.style.left=(Math.round((document.body.scrollWidth-200)/2)).toString()+"px"
}
</script>
<body onload="divcenter()" onresize=divcenter()>
<table width=100%>
<tr>
<td>test
</td>
</tr>
</table>
<div id=mxh style="position:absolute;left:200px;top:30px;width:200px;height:200px;background-color:navy;border:2px">测试文字</div>
</HTML>

孟子E章 2002-05-15
  • 打赏
  • 举报
回复
if(window.screen.Width==800)
document.all.login.style.left=200
else
document.all.login.style.left=400

孟子E章 2002-05-15
  • 打赏
  • 举报
回复
if(window.screen==800)
document.all.login.style.left=200
else
document.all.login.style.left=400

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧