简体   繁体   English

CSS:如何为页面上的特定表格(包括列和行)设置边框

[英]CSS: How to set border for a specific table on the page including columns and rows

I have page that has 3 tables. 我的页面有3个表格。

The table that I need has an id "tblContent" 我需要的表的ID为“ tblContent”

I set the border for the table: 我为表格设置边框:

#tblContent
{
    width:100%;
    border:1px solid black;
    border-collapse:collapse;
}

But this only sets border around the table. 但这只会在桌子周围设置边框。

How can I modify CSS to have the border for rows and columns as well? 如何修改CSS以使行和列也具有边框?

Add a border to the table cells as well. 也为表格单元格添加边框。

#tblContent td, #tblContent th {
    border:1px solid black;
}

 #tblContent { width: 100%; border: 1px solid black; border-collapse: collapse; } #tblContent td, #tblContent th { border: 1px solid black; } 
 <table id="tblContent" style="width: 100%"> <tr> <th>&nbsp;</th> <th>&nbsp;</th> <th>&nbsp;</th> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> 

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

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