CSS3 实现div方形小三角和对勾效果

本文介绍了一种使用纯CSS实现三角形图标和对勾图标的方案,并展示了如何在Vue项目中通过不同的类来切换元素的点击状态。此外,还提供了具体的代码示例。

 

1、ts

<div class="consultingRoom" :class="{ 'consultingRoomClick' : spanIndex.indexOf(index)>-1 }" v-for="(item,index) in stuRoomList" :key="item.roomId" :value="item.roomId" :title="item.roomName" @click="roomPich(item, index)">
    {{item.roomName}}
    <div :class="{'sjx':spanIndex.indexOf(index)>-1}"></div>
    <div :class="{'dg':spanIndex.indexOf(index)>-1}"></div>
  </div>

2、三角形和对勾css

  .sjx{
    margin-left:30px;
    width: 0;
    height: 0;
    position: absolute;
    right: 0px;
    bottom: 0px;
    border-bottom: 20px solid #1890ff;
    border-left: 20px solid transparent;
  }
  .dg{
    position: absolute;
    top: 19px;
    right: 0px;
    transform: rotate(14deg);
  }
  .dg:before {
    content: '\2713';
    color: #fff;
  }

3、点击样式

  .consultingRoom{
    display: inline-block;
    padding: 8px;
    margin-left: 15px;
    margin-bottom: 10px;
    border: 1px solid #e8e8e8;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    min-width: 120px;
    max-width: 120px;
    overflow:hidden;
    text-overflow:ellipsis;
    text-align: center;
    white-space: nowrap;
    word-break: break-all;
  }
  .consultingRoomClick{
    position: relative;
    display: inline-block;
    padding: 8px;
    margin-left: 15px;
    margin-bottom: 10px;
    border: 1px solid #409eff38;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    min-width: 120px;
    max-width: 120px;
    overflow:hidden;
    text-overflow:ellipsis;
    text-align: center;
    white-space: nowrap;
    word-break: break-all;
    color:#1890ff;
    background: #409eff38;
  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

沉默是金~

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值