【问题标题】:Gradient triangles [duplicate]渐变三角形[重复]
【发布时间】:2019-12-02 21:06:23
【问题描述】:

我知道怎么用css做一个三角形,但是渐变三角形?

我已经走到这一步了:

.triangle {
  width: 0;
  height: 0;
  border-left: 60px solid transparent;
  border-right: 60px solid transparent;
  border-bottom: 100px solid black;
}

.triangle {
  background-image: linear-gradient(to bottom right, black, blue);
}
<div class="triangle"></div>

【问题讨论】:

    标签: html css


    【解决方案1】:

    只需使用剪辑路径创建三角形:

    .triangle {
      width: 100px;
      height:86.6px; /* 0.866 * Width in order to have an equilateral triangle [0.866 = (sqrt(3)/2)] */
      background-image: linear-gradient(to bottom right, black, blue);
      clip-path:polygon(50% 0,100% 100%, 0 100%);
    }
    <div class="triangle"></div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 2014-10-12
      • 2016-12-02
      相关资源
      最近更新 更多