三角形,斜线,表头css实现方法

三角形可通过border来实现,斜线可用transform:rotate(9deg)

border可用来画三角形,主要是因为,长方形,四边的border可以单独设置颜色和粗细,border:1px solid #000
且border在content盒模型是不占宽高,当该长方形的宽高设置为0时,就剩下了border,就得到了三角形,其他的设成透明,就得到单个三角形

.border {
    width: 0;
    height: 0;
    border-style:solid;
    // 上面的border为0,下面的border为三角形的颜色
    border-width: 0 50px 50px;
    border-color: transparent transparent #d9534f;
}

如果想得到空心的,再用伪类元素定位个透明的三角形上去

.border:after {
    content: '';
    border-style: solid;
    border-width: 0 40px 40px;
    border-color: transparent transparent #fff;
    // 定位
    position: absolute;
    top: 6px;
    left: -40px;
}

表头如果有两色块用双三角形+position
请添加图片描述

 <th class="th-header"> 
  <div class="th-slash">
       <span class="th-content1">时间</span>
       <span class="th-content2">员工</span>
     </div>
</th>
.th-header{
  width:78px;
  height: 57px;
  // background: $t-b;
  // border:1px solid $br-m;
  .th-slash{
    border-top: 57px #D6D3D6 solid;
      /*上边框宽度等于表格第一行行高*/
      width: 0px;
      /*让容器宽度为0*/
      height: 0px;
      /*让容器高度为0*/
      border-left: 78px #BDBABD solid;
      /*左边框宽度等于表格第一行第一格宽度*/
      position: relative;
    .th-content1{
      position: absolute;
      bottom: 10px;
      left: -70px;
    }
    .th-content2{
      position: absolute;
      bottom: 30px;
      left: -34px;
    }
  }
}

表头如果有单色块用双tranform+position
请添加图片描述

<th class="th-header"> 
    <div class="th-slash" />
    <span class="th-content1">时间</span>
      <span class="th-content2">员工</span>
  </th>
.th-header{
  width:78px;
  height: 57px;
  position: relative;
  background: $t-b;
  border:1px solid $br-m;
  border-bottom: 2px solid $br-m;
  .th-slash{ 
    width: 1px;
    height: 92px;
    background: #e7e7e7;
    transform-origin: 0 0;
    transform: rotate(-54deg);
  }
  .th-content1{
      position: absolute;
      bottom: 10px;
      left: 6px;
      color:#bbbbbb;
    }
    .th-content2{
      position: absolute;
      bottom: 30px;
      right: 6px;
      color: #bbbbbb;
    }
}

参考:https://blog.csdn.net/weixin_44475093/article/details/116036349

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值