簡體   English   中英

HTML表格tr無國界

[英]HTML table tr with no borders

我需要使用HTML表,td,tr創建發票。 我需要這樣的東西

在此處輸入圖片說明

發票中的每個項目都在新行中,但是沒有邊框的行中。 我試圖為tr元素添加一個類

 border: 0px solid black;

但它不能正常工作。 你能告訴我嗎?

在此代碼段中創建了一個表格,但是到處都有邊框

 <!DOCTYPE html> <html> <head> <style> thead {color:green;} tbody {color:blue;} tfoot {color:red;} table, th, td { border: 1px solid black; } </style> </head> <body> <table> <thead> <tr> <th>Month</th> <th>Savings</th> </tr> </thead> <tfoot> <tr> <td>Sum</td> <td>$180</td> </tr> </tfoot> <tbody> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </tbody> </table> </body> </html> 

在CSS中使用邊框樣式(如下所示)在表格中刪除<tr> <td>邊框。

border-right:none;
border-left:none;
border-bottom:none;
border-top:none

解決了嗎?

為表格設置邊框,但是對於單元格,必須根據其位置為每個單元格指定一個自定義類。 我建議頂部,右側,展台和左側有4種邊界。 同樣不要忘記為表設置border-collapse來折疊彼此的TD邊界:

 table { border:1px solid #000000; border-collapse:collapse; } td{ padding:10px; } .tB{ border-top:1px solid #000000 } .rB{ border-right:1px solid #000000 } .bB{ border-bottom:1px solid #000000 } .lB{ border-left:1px solid #000000 } 
 <table> <tr> <td class="rB">test</td> <td class="bB">test</td> </tr> <tr> <td class="rB bB">test</td> <td class="bB">test</td> </tr> </table> 

您可以使用具有樣式屬性border:0的特定類來刪除單個行的邊框。 在下面找到解決方案(在代碼段頂部):

 tr.noBorder td { border: 0; } tr.noBorder td:first-child { border-right: 1px solid; } 
 <!DOCTYPE html> <html> <head> <style> thead {color:green;} tbody {color:blue;} tfoot {color:red;} table, th, td { border: 1px solid black; } </style> </head> <body> <table> <thead> <tr> <th>Month</th> <th>Savings</th> </tr> </thead> <tfoot> <tr> <td>Sum</td> <td>$180</td> </tr> </tfoot> <tbody> <tr class="noBorder"> <td>January</td> <td>$100</td> </tr> <tr class="noBorder"> <td>February</td> <td>$80</td> </tr> </tbody> </table> </body> </html> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM