1. Border
css
<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
css
.arrow {
width: 0;
height: 0;
border: 50px solid transparent;
border-right: 50px solid red;
transform: rotate(45deg);
}
3. :before 和 :after 伪元素
css
.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
css
.arrow {
width: 100px;
height: 100px;
background-color: red;
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}