拿来即用
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <style type="text/css"> .slash { width: 100px; height: 50px; background-color: #bbb; position: relative; padding: 0 !important; } .slash::before { content: ''; display: block; width: 100%; height: 100%; background-color: #eee; clip-path: polygon(0px 0.5px, 0px 100%, calc(100% - 0.5px) calc(100% + 0.5px)); position: absolute; top: 0; } .slash::after { content: ''; display: block; width: 100%; height: 100%; background-color: #eee; clip-path: polygon(100% calc(100% - 0.5px), 100% 0px, 0px -0.5px); position: absolute; top: 0; } </style> </head> <body> <table> <tbody> <tr> <td class="slash"></td> <td class="slash"> <span style="position: absolute;left: 6px;bottom: 4px;z-index: 1;color: #666;">aaa</span> <span style="position: absolute;right: 6px;top: 4px;z-index: 1;color: #666;">bbb</span> </td> </tr> </tbody> </table> </body> </html>