table表格表头单元格添加斜线

 

<!DOCTYPE html>
<html>
<head>
    <title>表格斜线</title>
    <style>
        html {
            height: 100%;
        }

        body {
            height: calc(100% - 16px);
        }

        .wrap {
            position: absolute;
            top: 75px;
            bottom: 20px;
            left: 50%;
            margin-left: -425px;
            width: 870px;
        }

        .tab-body {
            clear: both;
            width: 100%;
            height: 45%;
        }

            .tab-body h1 {
                padding: 15px 0;
                font-size: 20px;
                font-weight: bold;
                text-align: center;
            }

            .tab-body table {
                width: 100%;
                table-layout: fixed;
                border-collapse: collapse;
            }

                .tab-body table td, .tab-body table th {
                    height: 32px;
                    line-height: 32px;
                    padding: 5px;
                    border: #ddd 1px solid;
                    text-align: center;
                }

        .oblique-line {
            position: relative;
            width: 80px;
            line-height: 5px;
            text-align: left;
        }

            .oblique-line:before {
                content: "";
                position: absolute;
                width: 1px;
                height: 100px; /*斜线长度*/
                top: 0%;
                left: 0%;
                background-color: #ddd;
                display: block;
                transform: rotate(-65deg); /*调整角度*/
                transform-origin: top;
            }

        .left-bottom-div {
            height: 22px;
            line-height: 22px;
            position: absolute;
            left: 4px;
            bottom: 0px;
        }

        .right-top-div {
            height: 22px;
            line-height: 22px;
            position: absolute;
            right: 4px;
            top: 0px;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="tab-body">
            <table cellpadding="0" cellspacing="0" style="table-layout: fixed; width: 100%;">
                <thead>
                    <tr>
                        <th class="oblique-line">
                            <div>
                                <div class="left-bottom-div">子项</div>
                                <div class="right-top-div">月份</div>
                            </div>
                        </th>
                        <th>1</th>
                        <th>2</th>
                        <th>3</th>
                        <th>4</th>
                        <th>5</th>
                        <th>6</th>
                        <th>7</th>
                        <th>8</th>
                        <th>9</th>
                        <th>10</th>
                        <th>11</th>
                        <th>12</th>
                    </tr>
                </thead>
                <tbody id="thActualContent">
                </tbody>
            </table>
        </div>
    </div>
</body>
</html>

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值