在html5中不支持的cellpadding 和 cellspacing ; 2) 如何用css实现 cellpadding, cellspacing ; 3) tr , th 是 有 border, 没有 padding 的.时间:2023-12-04 13:28:321.初始: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>cellspacing的css实现</title> <style type="text/css"> table { border: 1px solid red; } td { border: 1px solid red; } </style> </head> <body> <h1>HTML5 不支持 <table> cellspacing 属性。</h1> <table> <tr> <td>单元格1-1</td> <td>单元格1-2</td> </tr> <tr> <td>单元格2-2</td> <td>单元格2-2</td> </tr> <tr> <td>单元格3-1</td> <td>单元格3-2</td> </tr> </table> </body> </html> 效果: 2. 通过css实现: cellspacing = 0; <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>cellspacing的css实现</title> <style type="text/css"> table { border: 1px solid red; border-collapse: collapse; } td { border: 1px solid red; } </style> </head> <body> <h1>HTML5 不支持 <table> cellspacing 属性。</h1> <table> <tr> <td>单元格1-1</td> <td>单元格1-2</td> </tr> <tr> <td>单元格2-2</td> <td>单元格2-2</td> </tr> <tr> <td>单元格3-1</td> <td>单元格3-2</td> </tr> </table> </body> </html> border-collapse: collapse; 是针对 <table>元素的. 效果: 3. css实现 cellspacing = xx; <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>cellspacing的css实现</title> <style type="text/css"> table { border: 1px solid red; border-collapse: separate; border-spacing: 20px; } td { border: 1px solid red; } </style> </head> <body> <h1>HTML5 不支持 <table> cellspacing 属性。</h1> <table> <tr> <td>单元格1-1</td> <td>单元格1-2</td> </tr> <tr> <td>单元格2-2</td> <td>单元格2-2</td> </tr> <tr> <td>单元格3-1</td> <td>单元格3-2</td> </tr> </table> </body> </html> 10 border-collapse: separate; 11 border-spacing: 20px; 1-- border-spacing 只有在 border-collapse : separate 时 才会起作用.2-- border-collapse, border-spacing 都是 针对 <table>元素的. 4. css实现 cellpadding <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>cellspacing的css实现</title> <style type="text/css"> table { border: 1px solid red; border-collapse: collapse; } td { border: 1px solid red; padding: 20px; } </style> </head> <body> <h1>HTML5 不支持 <table> cellspacing 属性。</h1> <table> <tr> <td>单元格1-1</td> <td>单元格1-2</td> </tr> <tr> <td>单元格2-2</td> <td>单元格2-2</td> </tr> <tr> <td>单元格3-1</td> <td>单元格3-2</td> </tr> </table> </body> </html> 1-- border-collapse 是针对 <table>元素的. padding 是针对 td 元素的. ----------------------------------------------------------------------------------------------------- 5. tr, th 有border . 没有 padding <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>cellspacing的css实现</title> <style type="text/css"> table { border: 1px solid red; border-collapse: collapse; } tr { border: 1px solid black; padding: 20px; } </style> </head> <body> <h1>HTML5 不支持 <table> cellspacing 属性。</h1> <table> <tr> <td>单元格1-1</td> <td>单元格1-2</td> </tr> <tr> <td>单元格2-2</td> <td>单元格2-2</td> </tr> <tr> <td>单元格3-1</td> <td>单元格3-2</td> </tr> </table> </body> </html> 效果: 参考链接: CSS中cellspacing和cellpadding属性用法揭秘相关文章在html5中不支持的cellpadding 和 cellspacing ; 2) 如何用css实现 cellpadding, cellspacing ; 3) tr , th 是 有 border, 没有 padding 的.上一篇:Vbscript写注册表的方法下一篇:luogu 1966 火柴排队 离散化+逆序对