使用css制作箭头
使用CSS制作箭头的方法
使用边框(Border)方法
通过设置元素的边框宽度和颜色,利用透明边框创建箭头效果。例如,制作一个向右的箭头:
.arrow-right {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid #000;
}
调整border-top、border-bottom和border-left的宽度可以改变箭头的大小和形状。
使用伪元素(::before或::after)
通过伪元素结合transform旋转和边框实现更灵活的箭头:
.arrow {
position: relative;
width: 100px;
height: 2px;
background: #000;
}
.arrow::after {
content: "";
position: absolute;
right: 0;
top: -4px;
width: 10px;
height: 10px;
border-right: 2px solid #000;
border-top: 2px solid #000;
transform: rotate(45deg);
}
调整transform: rotate()的角度可以改变箭头方向。

使用SVG内联
直接在HTML中嵌入SVG代码,通过CSS控制样式:
<div class="svg-arrow">
<svg viewBox="0 0 20 20" width="20" height="20">
<polygon points="0,0 20,10 0,20" fill="#000" />
</svg>
</div>
通过修改polygon的points属性可以调整箭头形状和方向。

使用clip-path
通过裁剪路径创建自定义箭头形状:
.clip-arrow {
width: 100px;
height: 40px;
background: #000;
clip-path: polygon(0% 20%, 60% 20%, 60% 0%, 100% 50%, 60% 100%, 60% 80%, 0% 80%);
}
使用在线工具生成clip-path的坐标值,可以设计更复杂的箭头。
使用Unicode字符
直接使用Unicode箭头字符,通过CSS调整大小和颜色:
<span class="unicode-arrow">→</span>
.unicode-arrow {
font-size: 24px;
color: #000;
}
Unicode提供了多种方向的箭头字符,如↑、↓、←、→等。






