【css】快速实现鼠标悬浮变色效果

在这里插入图片描述

<div class="nav-item">
     <div class="ic-img"></div>
     <div>切换</div>
</div>
    .nav-item {
   
        width: 100rem;
        height: 45rem;
        line-height: 45rem;
        display: flex;
        text-align: center;
        justify-content: center;
        align-items: center;
        color: white;
        cursor: pointer;

        .ic-img {
   
            width: 20px;
            height: 20px;
            margin-right: 5px;
            background-size: 100% 100%;
            background-image: url('@/assets/ic.png');
        }
        &:hover {
   
            color: #1be7e0;
            .ic-img {
   
                background-image: url('@/assets/ic-actived.png');
            }
        }
    }

关键点:把图片作为背景设置,以此实现Hover时动态切换的效果;

相关推荐

  1. css鼠标悬浮动效

    2024-01-09 16:34:03       30 阅读

最近更新

  1. vue配置sql规则

    2024-01-09 16:34:03       0 阅读
  2. ios 企业签名证书购买_iOS苹果企业签名须知

    2024-01-09 16:34:03       0 阅读
  3. android 使用系统工具bootchart统计开机时长

    2024-01-09 16:34:03       0 阅读
  4. 【工具分享】FOFA——网络空间测绘搜索引擎

    2024-01-09 16:34:03       0 阅读
  5. 物联网应用,了解一点 WWAN全球网络标准

    2024-01-09 16:34:03       0 阅读
  6. Jupyter Notebook详尽安装教程

    2024-01-09 16:34:03       1 阅读
  7. 实现淘客返利系统中的用户登录与权限管理

    2024-01-09 16:34:03       1 阅读

热门阅读

  1. CS22Python Facilities

    2024-01-09 16:34:03       39 阅读
  2. Redis服务器配置文件的常用配置

    2024-01-09 16:34:03       40 阅读
  3. Pickle文件读取——(待完善)

    2024-01-09 16:34:03       37 阅读
  4. git常用命令

    2024-01-09 16:34:03       33 阅读
  5. 什么是 DDoS 攻击

    2024-01-09 16:34:03       40 阅读
  6. sqlachemy orm create or delete table

    2024-01-09 16:34:03       41 阅读
  7. Linux C语言 51-IO复用

    2024-01-09 16:34:03       29 阅读
  8. PHP中excel带图片数据导入

    2024-01-09 16:34:03       38 阅读
  9. Python之面向对象

    2024-01-09 16:34:03       31 阅读