原理:css中的border属性的特殊性。

实心三角形:

html5:

<div ></div>


css:

#mydiv{
height: 0px;
width: 0px;
z-index: 1;/*这个与后面的空心三角形有关*/
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid red;
}
空心三角形:

只需要在原有的实心三角形的样式上加上:

#mydiv:after{
    content: '';
    z-index: 99;
    position: absolute;
    top: 9px;
    left: 10px;
    border-left: 48px solid transparent;
    border-right: 48px solid transparent;
    border-bottom: 98px solid white;
}

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-12-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-30
  • 2021-12-16
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
相关资源
相似解决方案