【问题标题】:Table showed different in IE from Opera表在 IE 中显示与 Opera 不同
【发布时间】:2010-10-04 19:06:37
【问题描述】:
我有一张表,上面有这样的代码:
<table cellpadding="6" rules="groups" frame="no">
<thead>
<tr><th>Date</th><th>Length</th><th>Time</th></tr>
</thead>
<tbody>
<tr><td>31. January1</td><td>28 km</td><td>3 hours</tr>
</tbody></table>
问题在于 IE 中的表格有框架和表格边框 = 1。
怎么办?
【问题讨论】:
标签:
html
internet-explorer
html-table
opera
【解决方案1】:
我希望它看起来像这样:
当我使用border="0" IE 时,不显示黑线。如果我写<th style="1p solid black>Text</th>,我会在表头周围看到一个黑框。
【解决方案2】:
border="0"
但是,你应该使用样式表来代替这样的事情......
【解决方案3】:
试试这个:
<!DOCTYPE html>
<html>
<head>
<title>Example:Table with Header Underline Border</title>
<style type="text/css">
table.groups
{
border-collapse: collapse;
}
table.groups thead th
{
border-bottom: solid 1px black;
}
table.groups th,
table.groups td
{
padding: 6px;
}
</style>
</head>
<body>
<table class="groups">
<thead>
<tr><th>Date</th><th>Length</th><th>Time</th></tr>
</thead>
<tbody>
<tr><td>31. January1</td><td>28 km</td><td>3 hours</td></tr>
</tbody>
</table>
</body>
</html>
需要注意的几个具体事项:
- 使用 DOCTYPE 来防止 quirks 模式。
(这是 HTML5 DOCTYPE - 有些人更喜欢罗嗦的 XHTML 或 HTML4 Strict 的 - 这些也可以)
- 标签上没有不必要的属性 - 全部由标签名称和类控制。
【解决方案4】:
使用
style="border:1px 纯黑色"
然后在表格标签中。
哦,最后一个单元格缺少一个结束符。