+ -
当前位置:首页 → 问答吧 → 背景可以设成拉伸吗?

背景可以设成拉伸吗?

时间:2004-06-01

来源:互联网

看了一下CSS,只提到平铺的重复,不重复
可不可以在一个表格中把一张图片拉伸作为背景?请赐教!谢谢!

作者: timwhoung   发布时间: 2004-06-01

前面发过了。

=================================================
<body>
<table>
<tr>
<td bgcolor=#cccccc id="s" style='border:1px solid #000000;position:relative;left:100px;top:100px;FONT:bold 12px Tahoma'> <font>TABLETABLETABLETABLETABLE<BR>TABLETABLETABLETABLETABLE<BR>TABLETABLETABLETABLETABLE<BR>TABLETABLETABLETABLETABLE<BR>TABLETABLETABLETABLETABLE<BR>TABLETABLETABLETABLETABLE<BR><font>
</td>
</tr>
</table>
<table>
<tr>
<td bgcolor=#cccccc id="s" style='border:1px solid #000000;position:relative;left:100px;top:100px;FONT:bold 12px Tahoma'> <font>TABLETABLETABLETABLETABLE<BR>TABLETABLETABLETABLETABLE<BR>TABLETABLETABLETABLETABLE<BR>TABLETABLETABLETABLETABLETABLETABLETABLETABLETABLE<BR><font>
</td>
</tr>
</table>
<script>
var n=document.all.s.length;
for(i=0;i<n;i++)
{

var TdHeight=document.all.s.offsetHeight-2;
var TdWidth=document.all.s.offsetWidth-2;
var interHTML="<img src=http://www.phpx.com/happy/avatar.php?userid=17889&dateline=1074682894 style='position:absolute;top:0px;left:0px;width:"
+TdWidth
+"px;height:"
+TdHeight
+"px;z-index:-1' id='oImg'>";
document.all.s.innerHTML+=interHTML;
}
</script>
<body>

=====================================

作者: longhorn   发布时间: 2004-06-01

试了一下,你贴的代码可以,但不知道如何使用,是使用绝对定位的吗?

作者: timwhoung   发布时间: 2004-06-01

是绝对定位。

把需要背景的<td>的 id设定成 "s"(你可以换,但后面的代码也得换,我是随便写的)
注意td 的 positon是relative

把<script>里面的代码
放到function window.onload(){            ,.....  }  函数之间。

作者: longhorn   发布时间: 2004-06-02

热门下载

更多