文章来源地址https://www.toymoban.com/news/detail-699746.html
1. Border
<div class="triangle"></div>
.triangle {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 14rpx solid red;
}
2. transform
.arrow {
width: 0;
height: 0;
border: 50px solid transparent;
border-right: 50px solid red;
transform: rotate(45deg);
}
3. :before 和 :after 伪元素
.arrow {
position: relative;
}
.arrow:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-right: 50px solid red;
}
4. clip-path
.arrow {
width: 100px;
height: 100px;
background-color: red;
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
文章来源:https://www.toymoban.com/news/detail-699746.html
到了这里,关于css实现三角形的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!