怎么使用 CSS 如何画一个三角形
参考答案
border 技巧
.triangle {
width: 0; height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 86px solid #1677ff; /* 朝上 */
}
原理:宽高为 0 时,border 交界处形成斜边,把其余三边设为透明即只剩一个三角。
其他方案
.clip { width:100px; height:100px; background:#1677ff;
clip-path: polygon(50% 0, 100% 100%, 0 100%); }
clip-path更灵活,可做任意多边形- 也可用
conic-gradient或 SVG 绘制