table 的表头

先来看一下效果图:

全部代码如下:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta content="ie=edge">
  <title>table 神奇的表头</title>
  <style>
    table {
      border-collapse: collapse;
    }

    table,
    tr,
    td {
      border: 1px solid black;
    }

    td {
      text-align: center;
      height: 50px;
      position: relative;
    }

    td[class=first] {
      width: 100px;
    }

    td[class=first]:before {
      content: "";
      position: absolute;
      width: 1px;
      height: 104px;
      top: 25px;
      left: 0;
      background-color: #000;
      display: block;
      transform: rotate(-75deg);
      transform-origin: top;
      -ms-transform: rotate(-75deg);
      -ms-transform-origin: top;
    }

    td[class=first]:after {
      content: "";
      position: absolute;
      width: 1px;
      height: 75px;
      top: 0;
      left: 50px;
      background-color: #000;
      display: block;
      transform: rotate(-45deg);
      transform-origin: top;
      -ms-transform: rotate(-45deg);
      -ms-transform-origin: top;
    }

    .title1 {
      position: absolute;
      top: 3px;
      right: 3px;
    }

    .title2 {
      position: absolute;
      top: 5px;
      left: 12px;
    }

    .title3 {
      position: absolute;
      top: 32px;
      left: 3px;
    }
  </style>
</head>

<body>
  <table>
    <tr>
      <td class="first" colspan="2">
        <span class="title1">产品</span>
        <span class="title2">销量</span>
        <span class="title3">地区</span>
      </td>
      <td>苹果</td>
      <td>华为</td>
      <td>小米</td>
    </tr>
    <tr>
      <td>1</td>
      <td>北京</td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>2</td>
      <td>天津</td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  </table>
</body>

</html>

 

转载于:https://www.cnblogs.com/likwin/p/10116149.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值