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