嵌套表格:1px 边框,带 css

发布于 2024-07-25 17:51:06 字数 339 浏览 2 评论 0原文

我正在尝试创建一个带有 1px 黑色边框的表格。

我必须在主表中嵌套一个表,并在下一个表与其封闭的 对接处获得“厚”边框。 我只想到处都有 1px 边框。

我实际上有这个:

table.outer{border:1px black solid; border-collapse: collapse;}
td{border:1px black solid; border-collapse: collapse;}
table.nexted{border:1px black solid; border-collapse: collapse;}

I'm trying to create a table with a 1px black border.

I have to nest a table in the main table, and get "thick" borders where the next table butts against its enclosing <td>. I just want a 1px border everywhere.

I have this, in effect:

table.outer{border:1px black solid; border-collapse: collapse;}
td{border:1px black solid; border-collapse: collapse;}
table.nexted{border:1px black solid; border-collapse: collapse;}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

_畞蕅 2024-08-01 17:51:06

如果我理解正确的话,您可以使用 border-left、border-right、border-top 和 border-bottom 来创建您想要的这些“特殊”情况。

例如,在嵌套表格中,您可以设置

border-left:0; 

在嵌套表格的左侧获得“结果”1 px 边框。

If I understand you correctly, you can use border-left, border-right, border-top and border-bottom to create these "special" cases you want.

For instance, in your nested tables you can set

border-left:0; 

to get a "resulting" 1 px border in the left side of the nested table.

撩动你心 2024-08-01 17:51:06

没有为嵌套表格提供边框样式

<!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>
    <title></title>
    <style type="text/css">
        table.outer
        {
            border: 1px black solid;
            border-collapse: collapse;
            width: 100%;
        }
        table.outer td
        {
            border: 1px black solid;
            border-collapse: collapse;
        }
        table.nested, table.nested td
        {
            border-width: 0px;
            border-collapse: collapse;
            width: 100%;
        }
    </style>
</head>
<body>
    <table class="outer">
        <tr>
            <td>
                <table class="nested">
                    <tr>
                        <td>
                             
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                    <tr>
                        <td>
                             
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                </table>
            </td>
            <td>
                content
            </td>
        </tr>
        <tr>
            <td>
                content
            </td>
            <td>
                <table class="nested">
                    <tr>
                        <td>
                             
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                    <tr>
                        <td>
                             
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>

give no border style for your nested table

<!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>
    <title></title>
    <style type="text/css">
        table.outer
        {
            border: 1px black solid;
            border-collapse: collapse;
            width: 100%;
        }
        table.outer td
        {
            border: 1px black solid;
            border-collapse: collapse;
        }
        table.nested, table.nested td
        {
            border-width: 0px;
            border-collapse: collapse;
            width: 100%;
        }
    </style>
</head>
<body>
    <table class="outer">
        <tr>
            <td>
                <table class="nested">
                    <tr>
                        <td>
                             
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                    <tr>
                        <td>
                             
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                </table>
            </td>
            <td>
                content
            </td>
        </tr>
        <tr>
            <td>
                content
            </td>
            <td>
                <table class="nested">
                    <tr>
                        <td>
                             
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                    <tr>
                        <td>
                             
                        </td>
                        <td>
                             
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
潦草背影 2024-08-01 17:51:06

只需将 border 属性放在 td 上即可。 如果你想要一个 1px 的边框,那就可以了; 你不需要把它放在桌子上。

Just put the border attribute on the tds. If you want a 1px border throughout, that'll do it; you don't need it on the tables.

£噩梦荏苒 2024-08-01 17:51:06

此页面描述了如何做得很好: http://www.visakopu.net /misc/table-border-css/

发生的情况是单元格上的边框相互碰撞,导致边框看起来比实际边框更厚。 您不使用 border-collapse 属性,而是在表格本身上设置边框,并且仅在顶部和左侧设置边框,并在单元格的下侧和右侧设置边框。

this page describes how to do it pretty well: http://www.visakopu.net/misc/table-border-css/

What's happening is that the borders on the cells are bumping up against each other, causing it to appear that there are thicker borders than there actually are. Instead of using the border-collapse property, you set a border on the table itself, and only on, say, the top and left sides, and you set borders on the lower and right sides for the cells.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文