This question already has answers here:
Make CSS3 triangle with linear gradient
                                
                                    (4个答案)
                                
                        
                                20天前关闭。
            
                    
我知道如何使用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>

最佳答案

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



.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>

关于html - 渐变三 Angular 形,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59139207/

10-12 02:24