vue css 实现选中div 边框变色,右下角三角形

vue 文件 + ant  框架实现

<a-row type="flex" justify="space-around" class="paySelect" gutter="[16,16]">
          <a-col :span="6">
        <div class="payItem" :class="currentIndex === 0 ? 'active' : ''" @click="currentIndex = 0">
          <img src="../../../../assets/icons/wechat1.png" alt=""> <span>微信支付</span>
          <div class="selected" v-if="currentIndex === 0"></div>
        </div>
      </a-col>
      <a-col :span="6">
        <div class="payItem" :class="currentIndex === 1 ? 'active' : ''" @click="currentIndex = 1">
          <img src="../../../../assets/icons/alipay.png" alt=""> <span>支付宝支付</span>
          <div class="selected" v-if="currentIndex === 1"></div>
        </div>
      </a-col>
      <a-col :span="6">
        <div class="payItem" :class="currentIndex === 2 ? 'active' : ''" @click="currentIndex = 2">
          <img src="../../../../assets/icons/unionpay.png" alt=""> <span>银联支付</span>
          <div class="selected" v-if="currentIndex === 2"></div>
        </div>
      </a-col>
    </a-row>

css 部分

 .selected{
    border-color: red;
  }
  .selected:after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    border-bottom: 30px solid red;
    border-left: 30px solid transparent;
  }
  .selected:before {
    content: '';
    position: absolute;
    width: 14px;
    height: 8px;
    background: transparent;
    top: 30px;
    right: 1px;
    border: 2px solid white;
    border-top: none;
    border-right: none;
    -webkit-transform: rotate(-55deg);
    -ms-transform: rotate(-55deg);
    transform: rotate(-55deg);
    z-index: 9;
  }

js 部分

data() {
    return {
      currentIndex: 0
    }
  },

效果如图: 

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值