html css 给td div添加斜线


拿来即用
<!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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM