用div +css模拟表格对角线

参考链接:css模拟对角线

<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>用div+css模拟表格对角线</title>
  <style type="text/css">
    * {
      padding: 0;
      margin: 0;
    }

    caption {
      font-size: 14px;
      font-weight: bold;
    }

    table {
      border-collapse: collapse;
      border: 1px #525152 solid;
      width: 50%;
      margin: 0 auto;
      margin-top: 100px;
    }

    th,
    td {
      border: 1px #525152 solid;
      text-align: center;
      font-size: 12px;
      line-height: 30px;
      background: #C6C7C6;
    }

    th {
      background: #D6D3D6;
    }

    /*模拟对角线*/
    .out {
      border-top: 40px #D6D3D6 solid;
      /*上边框宽度等于表格第一行行高*/
      width: 0px;
      /*让容器宽度为0*/
      height: 0px;
      /*让容器高度为0*/
      border-left: 80px #BDBABD solid;
      /*左边框宽度等于表格第一行第一格宽度*/
      position: relative;
      /*让里面的两个子容器绝对定位*/
    }

    b {
      font-style: normal;
      display: block;
      position: absolute;
      top: -40px;
      left: -40px;
      width: 35px;
    }

    em {
      font-style: normal;
      display: block;
      position: absolute;
      top: -25px;
      left: -70px;
      width: 55x;
    }

    .t1 {
      background: #BDBABD;
    }
  </style>
</head>

<body>
  <table>
    <caption>用div+css模拟表格对角线</caption>
    <tr>
      <th style="width:80px;">
        <div class="out">
          <b>类别</b>
          <em>姓名</em>
        </div>
      </th>
      <th>年级</th>
      <th>班级</th>
      <th>成绩</th>
      <th>班级均分</th>
    </tr>
    <tr>
      <td class="t1">张三</td>
      <td></td>
      <td>2</td>
      <td>62</td>
      <td>61</td>
    </tr>
    <tr>
      <td class="t1">李四</td>
      <td></td>
      <td>1</td>
      <td>48</td>
      <td>67</td>
    </tr>
    <tr>
      <td class="t1">王五</td>
      <td></td>
      <td>5</td>
      <td>79</td>
      <td>63</td>
    </tr>
    <tr>
      <td class="t1">赵六</td>
      <td></td>
      <td>4</td>
      <td>89</td>
      <td>66</td>
    </tr>
  </table>
</body>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值