1

I know how to make a triangle with css, but a gradient triangle?

I got this far:

.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>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Fresh
  • 51
  • 8

1 Answers1

2

Simply use clip-path to create the triangle:

.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>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415