我開發了一個帶有CSS和圖形的漂亮表格框架。它使用3D背景的背景圖像切片和行的簡單css邊界。不同瀏覽器中的單元格背景/邊框不對齊
問題是我需要將邊框與標題對齊,並且它不會在不同的瀏覽器中始終如一地工作,儘管我看不出爲什麼。
在IE6和IE7它的工作原理確定
在IE8和FF3.5左邊緣出一個像素
在Chrome中10右邊緣出一個像素
似乎背景圖像沒有完全放置在標題單元格的邊緣,但很難知道哪個瀏覽器應該受到指責。任何建議感激。
問題的現場演示是: http://www.songtricks.com/TableBug.html
的HTML/CSS源代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
table.demo
{
margin:0px;
padding:0px;
border-collapse:collapse;
}
table.demo tr
{
padding:0px;
border:none 0px transparent;
}
table.demo th
{
border:none 0px transparent;
border-bottom:solid 1px #cccccc;
padding:10px;
background:url(wfx_table_tm.gif) repeat-x left top;
}
table.demo th.left
{
padding:0px;
background:url(wfx_table_tl.gif) no-repeat left top;
}
table.demo th.right
{
padding:0;
background:url(wfx_table_tr.gif) no-repeat right top;
}
table.demo td
{
border:none 0px transparent;
border-right:solid 1px #dfdfdf;
border-bottom:solid 1px #cccccc;
padding:8px;
}
table.demo td.left
{
border-left:solid 1px #b1b1b1;
}
table.demo td.right
{
border-right:solid 1px #b1b1b1;
}
</style>
</head>
<body>
<table class="demo">
<tr>
<th class="left">Left</th>
<th>Center</th>
<th class="right">Right</th>
</tr><tr>
<td class="left">Left</td>
<td>Center</td>
<td class="right">Right</td>
</tr>
</table>
</body>
</html>
穆薩爾,聳人聽聞的感謝!這就是訣竅,我之前並不知道邊界間距。多好的一招。我已經用下面的技術添加了ie6/7條件覆蓋,你認爲這是最好的方法嗎?再次感謝!/* IE6 hack */* html table.demo {border-collapse:collapse; }/* IE7 hack */*:first-child + html table.demo {border-collapse:collapse; } – Stephen 2011-04-20 00:52:32
我不擔心IE6和IE7黑客的「最好」。如果他們工作,然後將其稱爲完成,並繼續前往更有趣和有趣的事情。儘可能使CSS選擇器儘可能具體,以隔離這些雜物。 – 2011-04-20 01:27:01
我同意* mu *,因爲如果黑客對任何版本的IE都有效,那麼將其稱爲完成。除非您要使用瀏覽器特性無法分離的大塊CSS,您可以將它們放在單獨的文件中,並使用[if IE]註釋的部分包含它,如http://www.gkspk .com/view/programming/minimum-and-maximum-widths-in-ie6 /(免責聲明:無障礙插件到我的網站。):p – musaul 2011-04-20 12:25:30