html中怎样把背景图片居中,不要css的

如题所述

背景图片不用CSS控制不了 要是插入的图片用table也可以居中
<table width="900" height="500" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"<img src="/Images/2.gif" width="800" height="230" /></td>
</tr>
</table>

用样式是这样的
<style>
.main{width:980px; height:500px; margin:0 auto; background:url(Images/2.gif) no-repeat center; overflow:hidden;}
</style>
</head>
<body>
<div class="main">
</div>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-12-03
<script type="text/javascript">
document.body.style.background="#FFCC80 url(img/kenan.jpg) no-repeat top center";
</script>

#ffcc80是背景色,url(img/kennan.jpg)是图片地址,no-repeat top center是图片不重复居中来自:求助得到的回答
第1个回答  2012-12-03
无语,背景图片居然不许用css,那你可以写更复杂的javascript也是可以的,如果你会的话。追问

没办法啊,作业要求

第2个回答  2012-12-02
在标签前面后面加入<center></center>