此问题之前曾在CSS: Make a block element fill the entire space of a parent element?
提出(并已回答)但是,接受的解决方案在CHROME中不起作用(如mercator的评论中所述)。修正建议将高度:100添加到< tr>元素也不起作用。有谁知道如何使用基于webkit的浏览器实现这种效果?链接http://dl.getdropbox.com/u/26620/stackoverflow1.html(由原始海报提供)显示了此问题。它适用于FF / IE但不适用于Chrome。
感谢。
答案 0 :(得分:1)
我在Chrome中尝试了这个功能,它看起来效果很好:http://apptools.com/examples/tdcolor.php
这是css(称之为test.css):
table.navbar {
border-collapse: collapse;
}
table.navbar td {
border: 1px solid #ccc;
}
table.navbar td a{
display: block;
width: 9em;
padding: 3px;
text-decoration: none;
}
table.navbar td a:link, table.navbar td a:visited {
color: #000;
background-color: #fff;
}
table.navbar td a:hover, table.navbar td a:active {
color: #fff;
background-color: #666;
}
示例html文件(记得更改test.css文件的路径):
<html>
<head>
<link rel='stylesheet' href='CHANGE PATH TO YOUR test.css' type='text/css' media='all' />
</head>
<body>
<p><strong>Example:</strong></p>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td><table border=0 cellspacing=0 cellpadding=0 class=navbar>
<tr>
<td class=navbar><a href="javascript:void(0);">First that is very, very, long to make sure that everything is working correctly <b
style="color:black;background-color:#a0ffff">Link</b></a></td>
</tr>
<tr>
<td class=navbar><a href="javascript:void(0);">Another <b style="color:black;background-color:#a0ffff">Link</b></a> </td>
</tr>
<tr>
<td class=navbar><a href="javascript:void(0);">A Third <b style="color:black;background-color:#a0ffff">Link</b></a> </td>
</tr>
</table></td>
<td valign=top class=othercontent><p>Other content goes here.</p></td>
</tr>
</table>
</body>
</html>
这对你有用吗?