简体   繁体   English

为什么 tr 的边框不显示,除非父表标签的边框折叠属性设置为折叠?

[英]Why does the border of tr not show unless the parent table tag has the border-collapse property set to collapse?

html: html:

            <table>
                <tr>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                </tr>
            </table>

css: css:

        table {
            height: 20px;
            width: 30px;
            border: solid 1px;
            border-collapse: collapse;
        }

        tr {
            border: 1px solid;
        }

Here is an image of the table:这是一张桌子的图片:

行显示边框

If I comment out border-collapse: collapse;如果我注释掉border-collapse: collapse; under table in the css, the row borders disappear:在 css 的表格下,行边框消失:

行不显示边框

In this link: https://developer.mozilla.org/en-US/docs/Web/CSS/border-collapse there is an example table where the borders are not collapsed(but set to separate, and that doesn't seem to make the borders on my example reappear either):在此链接中: https://developer.mozilla.org/en-US/docs/Web/CSS/border-collapse有一个示例表,其中边框没有折叠(但设置为分离,这似乎没有使我的示例的边框重新出现):

来自 Mozilla 的表格示例

Here there are gaps between the red and orange borders.这里红色和橙色边界之间有间隙。 Why does my original table not show the row borders at all when the border-collapse property is commented out, instead of showing borders with gaps like in this mozilla example, or something visible at all?为什么当边框折叠属性被注释掉时,我的原始表格根本不显示行边框,而不是像这个 mozilla 示例中那样显示带间隙的边框,或者根本不可见的东西?

i think you need to add border to "td".我认为您需要为“td”添加边框。 like:喜欢:

 tr,td { border: 1px solid black; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM