使用 CSS 移除不需要的表格单元格边框 [英] Removing unwanted table cell borders with CSS

查看:32
本文介绍了使用 CSS 移除不需要的表格单元格边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪而令人沮丧的问题.对于简单的标记:

I have a peculiar and frustrating problem. For the simple markup:

<table>
    <thead>
        <tr><th>1</th><th>2</th><th>3</th></tr>
     </thead>
    <tbody>
        <tr><td>a</td><td>b></td><td>c</td></tr>
        <tr class='odd'><td>x</td><td>y</td><td>z</td></tr>
    </tbody>
</table>

我将不同的背景颜色值应用于 theadtrtr 奇数元素.问题是在大多数浏览器中,每个单元格都有一个不需要的边框,它不是任何表格行的颜色.只有在 Firefox 3.5 中,表格在任何单元格中都没有边框.

I apply different background-color values to the thead, tr, and tr odd elements. The problem is that in most browsers, every cell has an unwanted border which is not the color of any of the table rows. Only in Firefox 3.5 does the table have no borders in any cell.

我只想知道如何在其他主要浏览器中删除这些边框,以便您在表格中看到的唯一内容是交替的行颜色.

I'd just like to know how to remove these borders in the other major browsers so that the only thing you see in the table are the alternating row colors.

推荐答案

您需要将此添加到您的 CSS 中:

You need to add this to your CSS:

table { border-collapse:collapse }

这篇关于使用 CSS 移除不需要的表格单元格边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆