【CSS】实现tag选中对钩样式

样式效果:

代码实现:(纯css,伪类实现)

html 复制代码
<div class="item" v-for="i in 3" :key="i" :class="i===1?'selected':''">{{ i }}</div>


<style>
    .item {
      padding: 6px 12px;
      background-color: #ffffff;
      border: 1px solid #ddd;
      width: 40px;
      margin: 10px;
      text-align: center;
      display: inline-block;

      position: relative;   // 必须有
    }

    .selected {
      border-color: #14BCF5;
    
      &:before {        // 三角形背景
        content: "";
        position: absolute;
        right: 0;
        bottom: 0;
        border: 10px solid #14BCF5;
        border-top-color: transparent;
        border-left-color: transparent;
      }

      &:after {        // 对钩
        content: "";
        width: 6px;
        height: 8px;
        position: absolute;
        right: 3px;
        bottom: 3px;
        border: 1px solid #fff;
        border-top-color: transparent;
        border-left-color: transparent;
        transform: rotate(45deg);
      }
    }
</style>
相关推荐
SoaringHeart8 分钟前
Flutter进阶:基于 EasyRefresh 的下拉刷新封装 n_easy_refresh_mixin.dart
前端·flutter
IT_陈寒2 小时前
Vite的热更新突然不香了,排查三小时差点砸键盘
前端·人工智能·后端
子兮曰2 小时前
Agency-Agents 深度解析:400+ AI 专家的"梦之队"如何重塑开发工作流
前端·后端·vibecoding
竹林8183 小时前
用 The Graph 查询链上数据实战:从手搓 RPC 到 Subgraph,我的 NFT 项目数据加载快了 10 倍
前端·javascript
妙码生花3 小时前
从 PHP 到 AI + Golang,程序员自救转型手记(十九):点选验证码代码逐行目检
前端·后端·go
Awu12274 小时前
⚡从零开发 Agent CLI(五)实现一个可治理、可扩展的工具系统
前端·人工智能·claude
咪库咪库咪5 小时前
Vue3-生命周期
前端
莪_幻尘5 小时前
你的 AI Skill 越多越蠢?Token 上下文爆炸的求生指南
前端·ai编程
lichenyang4535 小时前
从 has.echo 到异步 API 注册表:一次 ASCF API 回调不触发的排查复盘
前端
林瞅瞅6 小时前
Nuxt3 项目部署 Nginx 防盗链后特定 JS 文件 403 问题修复方案
前端