asp.net div随分辨率变化而变化

zhoubupt 2010-03-16 10:53:27
<form>
<div style="width:100%" >
<div id="head">
<table style="width:100%;" border="0px" cellpadding="0px" cellspacing="0" align="center">
<tr>
<td style="width:29.2%;height:91px;background: url(images/1.jpg) repeat-x;"></td>
<td style="width:40.4%;height:91px;background: url(images/2.jpg) repeat-x;"><h1>系</h1></TD>
<td style="width:20.4%;height:91px;background: url(images/4.jpg) repeat-x;"></td>
<td style="width:10%;height:91px;background: url(images/3.jpg) repeat-x;"></td>
</tr>
</table>
</div>
</div>
</form>
我的分辨率是1024*768显示没有问题,但在别人宽屏上时,右边出现很大白空隙,怎么让div随分辨率变化而变化。谢谢
...全文
143 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Joson.e8love 2010-03-17
  • 打赏
  • 举报
回复
做这个干嘛啊 郁闷 如果你用的背景 随分辨率变了 背景会怎么样?
如果你用了 背景重复?那么如果背景不是单一的呢?
分辨率本来就是有区别的 你能保证你把所有的分辨率都做出来?

你能做的是 浏览器兼容 分辨率兼容好像很难 不过肯定是可以做几个常用分辨率的

哎 做浏览器兼容就可以了
koukoujiayi 2010-03-17
  • 打赏
  • 举报
回复
大致的js代码:
给出分辨率小于800和大于800设置div1的代码,其中x1,y1,x2,y2自己定义!!
     function SetHeight() {
       var hei = window.screen.height;
       // var hei1 = document.body.clientHeight;
       if (hei <= 800) {
         document.getElementById("div1").style.height = x1;
         document.getElementById("div1").style.height = y1;
       }
       else if (hei > 800) {
         document.getElementById("div1").style.height = x2;
         document.getElementById("div1").style.height = y2;
       }
     }
Alden 2010-03-17
  • 打赏
  • 举报
回复
设置为百分比可能能好点。
teerhu 2010-03-17
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 zhangyumei 的回复:]
<div id="head"> 这个的 width 是多少? table 的width 你设了100%,是相对于它的上层容器---- <div id="head">来说的,而<div id="head">如果没有设置width 的话,很容易出现你说的问题的
[/Quote]
up
zhangyumei 2010-03-17
  • 打赏
  • 举报
回复
<div id="head"> 这个的 width 是多少? table 的width 你设了100%,是相对于它的上层容器---- <div id="head">来说的,而<div id="head">如果没有设置width 的话,很容易出现你说的问题的
telankes2000 2010-03-16
  • 打赏
  • 举报
回复
try

<td style="width:10%;height:91px;background: url(images/3.jpg) repeat-x;"></td> ==>
<td style="width:auto;height:91px;background: url(images/3.jpg) repeat-x;"></td>

zhoubupt 2010-03-16
  • 打赏
  • 举报
回复
具体怎麽用,网上找了些,说body.clientWidth不是left属性之类,能给点代码么我试试么
WoooXVi 2010-03-16
  • 打赏
  • 举报
回复
用js吧
检查当前浏览器宽度,变化了的话,就调节详细的内容(兼容性比较好一点)
zhoubupt 2010-03-16
  • 打赏
  • 举报
回复
能详细点么?怎么来用,谢谢
cystudio 2010-03-16
  • 打赏
  • 举报
回复
screen.height
screen.width

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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