2011-12-21 83 views
0

我做了一个简单的HTML页面,其上显示图像作为标题。问题是图像不重复。背景重复不起作用

当我将width设置为100%时,td(side)消失。 如果我从basestrip删除width,那么它只覆盖屏幕区域的一半。我想要覆盖具有指定高度的图像的所有屏幕。

<table cellpadding="0" cellspacing="0"> 
    <tr> 
     <td id="side" width="10px" height="25px"></td> 
     <td></td> 
     <td id="basestrip" width="100%" height="25px"> 
        </td> 
      </tr> 
</table> 

这是CSS:

#side { 
background-color: #014160; 
} 

#basestrip { 
    background-image: url('../Images/topstripbg.png'); 
    background-repeat: repeat-x;  
} 
+0

财产你尝试过将背景图像到'tr'元素,而不是'td'? – Aaron 2011-12-21 06:11:44

+0

你在布置一个使用表格的网站?另外,给#basetrip宽度为90%,#宽度为8%,看看侧面是否停留。 – Indranil 2011-12-21 06:13:55

+1

也检查图像路径是否正确,可能是它没有加载图像.. – 2011-12-21 06:18:24

回答

0

尝试添加宽度=“100%”(或更好的风格=“宽度:100%”,甚至更好地运用宽的CSS样式:100%)你的桌子。通过你的代码,单元格占用了100%的表格。但该表默认采用所有单元格的内容大小。

+0

我所做的是...给表中的100%,并在tr中设置图像,然后休息我已经应用了CSS。 – 2011-12-21 08:53:50

0

首先,该元件不具有高度特性,可应用于。你也不能将'px'附加到html标签的高度或宽度属性上,这只适用于CSS。我认为这个表格应该是浏览器窗口的宽度,高25像素,1行3格,第一个宽10px,第二个你没有指定,最后一个你有100%。这里是我的跨浏览器的方法:

<html> 
    <head> 
    <style type="text/css"> 
     #thetable { width:100%; height:25px; } 
     #thetable>tr { height: 25px } 
     #thetable>tr>td#side { width: 10px } 
     #thetable>tr>td#basestrip { background: url('../Images/topstripbg.png') repeat-x; } 
    </style> 
    </head> 

    <body> 
    <table id="thetable" width="100%" cellpadding="0" cellspacing="0"> 
     <tr> 
     <td id="side" width="10"></td> 
     <td width="auto"></td> 
     <td id="basestrip" width="100%"></td> 
     </tr> 
    </table> 
    </body> 
</html> 
0

采取这样

#basestrip { background: url('../Images/topstripbg.png') repeat-x; }