用css绘制三角形

一、

.tri1 {
            width: 0; height: 0;
            border-color: red blue red blue;
            border-width: 50px 50px 50px 50px;
            border-style: solid;
     }

在这里插入图片描述
二、

.tri2 {
            width: 0; height: 0;
            border-color: red blue blue red;
            border-width: 50px 50px 50px 50px;
            border-style: solid;
        }

在这里插入图片描述
三、

.tri3 {
            width: 0; height: 0;
            border-color: transparent red; /*上下颜色 左右颜色*/
            border-width: 0 0 50px 50px;
            border-style: solid;
        }

在这里插入图片描述
四、

.tri4 {
            width: 0; height: 0;
            border-color: red transparent; /*上下颜色 左右颜色*/
            border-width: 0 0 50px 50px;
            border-style: solid;
        }

在这里插入图片描述
五、

.tri5 {
            width: 0; height: 0;
            border-color: red transparent; /*上下颜色 左右颜色*/
            border-width: 0 50px 50px 0;
            border-style: solid;
        }

在这里插入图片描述
六、

.tri6 {
            width: 0; height: 0;
            border-color: transparent red; /*上下颜色 左右颜色*/
            border-width: 0 50px 50px 0;
            border-style: solid;
        }

在这里插入图片描述
七、绘制五角星

 /*五角星 由三个等边三角形拼接而成*/
        #star-five {
            position: relative;
            width: 0; height: 0;
            border-left: 100px solid transparent;
            border-right: 100px solid transparent;
            border-bottom: 70px solid #039ae9;
            transform: rotate(35deg);
            margin: 50px;
        }
        #star-five::before {
            content: "";
            position: absolute; top: 3px; right: -95px;
            width: 0; height: 0;
            border-left: 100px solid transparent;
            border-right: 100px solid transparent;
            border-bottom: 70px solid #039ae9;
            transform: rotate(-70deg);
        }
        #star-five::after {
            content: "";
            position: absolute; top: 6px; right: -96px;
            border-left: 100px solid transparent;
            border-right: 100px solid transparent;
            border-bottom: 70px solid #039ae9;
            transform: rotate(-145deg);
        }

在这里插入图片描述
八、Triangle Up

 #triangle-up {
      width: 0;
      height: 0;
      border-left: 50px solid transparent;
      border-right: 50px solid transparent;
      border-bottom: 100px solid red;
    }

在这里插入图片描述
九、Triangle Down

 #triangle-down {
      width: 0;
      height: 0;
      border-left: 50px solid transparent;
      border-right: 50px solid transparent;
      border-top: 100px solid red;
    }

在这里插入图片描述
十、Triangle Left

#triangle-left {
      width: 0;
      height: 0;
      border-top: 50px solid transparent;
      border-right: 100px solid red;
      border-bottom: 50px solid transparent;
    }

在这里插入图片描述
A、Triangle Right

#triangle-right {
      width: 0;
      height: 0;
      border-top: 50px solid transparent;
      border-left: 100px solid red;
      border-bottom: 50px solid transparent;
    }

在这里插入图片描述
B、Curved Tail Arrow
在这里插入图片描述

 #curvedarrow {
      position: relative;
      width: 0;
      height: 0;
      border-top: 9px solid transparent;
      border-right: 9px solid red;
      transform: rotate(10deg);
    }
    #curvedarrow:after {
      content: "";
      position: absolute;
      border: 0 solid transparent;
      border-top: 3px solid red;
      border-radius: 20px 0 0 0;
      top: -12px;
      left: -9px;
      width: 12px;
      height: 12px;
      transform: rotate(45deg);
    }

C、Pentagon
在这里插入图片描述

  #pentagon {
      position: relative;
      width: 54px;
      box-sizing: content-box;
      border-width: 50px 18px 0;
      border-style: solid;
      border-color: red transparent;
    }
    #pentagon:before {
      content: "";
      position: absolute;
      height: 0;
      width: 0;
      top: -85px;
      left: -18px;
      border-width: 0 45px 35px;
      border-style: solid;
      border-color: transparent transparent red;
    }

D、Heart (via Nicolas Gallagher)
在这里插入图片描述

#heart {
      position: relative;
      width: 100px;
      height: 90px;
    }
    #heart:before,
    #heart:after {
      position: absolute;
      content: "";
      left: 50px;
      top: 0;
      width: 50px;
      height: 80px;
      background: red;
      border-radius: 50px 50px 0 0;
      transform: rotate(-45deg);
      transform-origin: 0 100%;
    }
    #heart:after {
      left: 0;
      transform: rotate(45deg);
      transform-origin: 100% 100%;
    }

E、Infinity
在这里插入图片描述

 #infinity {
      position: relative;
      width: 212px;
      height: 100px;
      box-sizing: content-box;
    }
    #infinity:before,
    #infinity:after {
      content: "";
      box-sizing: content-box;
      position: absolute;
      top: 0;
      left: 0;
      width: 60px;
      height: 60px;
      border: 20px solid red;
      border-radius: 50px 50px 0 50px;
      transform: rotate(-45deg);
    }
    #infinity:after {
      left: auto;
      right: 0;
      border-radius: 50px 50px 50px 0;
      transform: rotate(45deg);
    }
  

F、Yin Yang
在这里插入图片描述

 #yin-yang {
      width: 96px;
      box-sizing: content-box;
      height: 48px;
      background: #eee;
      border-color: red;
      border-style: solid;
      border-width: 2px 2px 50px 2px;
      border-radius: 100%;
      position: relative;
    }
    #yin-yang:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0;
      background: #eee;
      border: 18px solid red;
      border-radius: 100%;
      width: 12px;
      height: 12px;
      box-sizing: content-box;
    }
    #yin-yang:after {
      content: "";
      position: absolute;
      top: 50%;
      left: 50%;
      background: red;
      border: 18px solid #eee;
      border-radius: 100%;
      width: 12px;
      height: 12px;
      box-sizing: content-box;
    }

G、Pointer
在这里插入图片描述

  #pointer {
      width: 200px;
      height: 40px;
      position: relative;
      background: red;
    }
    #pointer:after {
      content: "";
      position: absolute;
      left: 0;
      bottom: 0;
      width: 0;
      height: 0;
      border-left: 20px solid white;
      border-top: 20px solid transparent;
      border-bottom: 20px solid transparent;
    }
    #pointer:before {
      content: "";
      position: absolute;
      right: -20px;
      bottom: 0;
      width: 0;
      height: 0;
      border-left: 20px solid red;
      border-top: 20px solid transparent;
      border-bottom: 20px solid transparent;
    }
  

————————————————
更多css绘制的图形请参考:
https://css-tricks.com/the-shapes-of-css/
方法参考:https://blog.csdn.net/w214019153/article/details/52469866

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值