CSS画箭头

向右示例

.arrows {
  height: 7px;
  width: 7px;
  background-color: transparent;
  border-top: 2px solid rgba(0, 0, 0, 0.3);
  border-right: 2px solid rgba(0, 0, 0, 0.3);
  transform: rotate(45deg);
  margin-left: 6px;
}

可以尝试将其封装为组件(以微信小程序为例)

<!-- 向右 -->
<view class="arrows" style="width: {{size}}; height: {{size}}; border-top: 2px solid {{color}}; border-right: 2px solid {{color}}; margin-left: 6px;" wx:if="{{right}}"></view>

<!-- 向左 -->
<view class="arrows" style="width: {{size}}; height: {{size}}; border-left: 2px solid {{color}}; border-bottom: 2px solid {{color}}; margin-right: 6px;" wx:if="{{left}}"></view>

<!-- 向上 -->
<view class="arrows" style="width: {{size}}; height: {{size}}; border-left: 2px solid {{color}}; border-top: 2px solid {{color}}; margin-right: 6px;" wx:if="{{top}}"></view>

<!-- 向下 -->
<view class="arrows" style="width: {{size}}; height: {{size}}; border-right: 2px solid {{color}}; border-bottom: 2px solid {{color}}; margin-right: 6px;" wx:if="{{bottom}}"></view>

其中size、color、方向由参数传递

properties: {
    size: {
      type: String,
      value: "7px"
    },
    direction: {
      type: String,
      value: "right"
    },
    color: {
      type: String,
      value: "rgba(0,0,0,0.3)"
    }
  },

使用:

<arrows direction="right" size="10px"></arrows>
    <arrows direction="left" color="red"></arrows>
    <arrows direction="top" color="#34ff55"></arrows>
    <arrows direction="bottom" color="rgba(0,0,0,0.6)"></arrows>

效果:

不同前端可能封装过程不一样,可以自行确定

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值