Element中的meau的图标高亮显示

先列出关键代码

html 复制代码
.el-submenu__title:hover i{
  color: white !important;
}

本页全部代码

html 复制代码
<script>

</script>

<template>
  <div>
    <el-container>
      <!--    侧边栏-->
      <el-aside style="width: 200px;min-height: 100vh;background-color: #001529; border-radius: 4px;">
<!--        这里,min-height: 100vh;可以设置侧边栏的高度,默认是100%,这样可以充满整个页面。,同时,就可以把滚动条去掉-->
        <div style="height: 60px; line-height: 60px; color: white; display: flex; justify-content: center; align-items: center;">
          logo
        </div>

        <el-menu active-text-color="white" text-color="rgba(255,255,255,0.65)" background-color="#001529" router style="border: none;" :default-active="$route.path">
          <el-menu-item index="/">
            <i class="el-icon-house"></i>
            <span>系统首页</span>
          </el-menu-item>
          <el-menu-item index="/element">element首页</el-menu-item>
          <el-menu-item>系统首页</el-menu-item>
          <el-menu-item>系统首页</el-menu-item>
          <el-submenu>
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>系统设置</span>
            </template>
            <el-menu-item>信息管理</el-menu-item>
            <el-menu-item>管理员信息</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!--    主体内容-->
      <el-container>
        <el-header>
          头部

        </el-header>

        <el-main>
          主体
          <router-view></router-view>
        </el-main>
      </el-container>

    </el-container>
  </div>
</template>

//样式不生效,直接无脑加一个 !important  解决
<style>
.el-menu--inline .el-menu-item{
  background-color: #000c16 !important;
}
.el-menu-item:hover,.el-submenu__title:hover{
  color: white !important;
}
.el-submenu__title:hover i{
  color: white !important;
}
</style>

注意点:

下面的写法只有鼠标放在,图标(i)上门的时候才会显示高亮,这与我们的需求:鼠标移动到一个上的时候,里面的东西全部高亮不是一个效果

html 复制代码
.el-submenu__title>i:hover{
  color: white !important;
}
相关推荐
小爬的老粉丝1 小时前
JavaScript 纯前端预览 WPS:先识别容器,再路由解析器
前端·javascript·wps
满栀5852 小时前
状态管理:Redux、Vuex、Pinia 核心区别
前端·javascript·typescript
大龄码农有梦想4 小时前
Vue + BPMN.js + Camunda:搭建企业级流程设计器完整实践
javascript·vue.js·流程设计器·bpmn.js·bpmn·流程审批·工作流设计器
Eloudy5 小时前
ReAct 原理简介
前端·javascript·人工智能·react.js·agent·gpu
ZJU_统一阿萨姆6 小时前
【DSH】如何将 DeepSeek Harness 嵌入生产环境?万字解构 DeepSeek Agent Harness 的运行机制与安全边界
前端·javascript·安全
夏天一说说7 小时前
API 安全】API-Pentest:基于 JS 分析 + AI Agent 的自动化 API 渗透测试工具实战指南
javascript·人工智能·安全·api
sunly_7 小时前
TypeScript总结:16、面向对象速查
前端·javascript·typescript
张元清7 小时前
React useInterval Hook:没有过期闭包的 setInterval (2026)
javascript·react.js
MXN_小南学前端7 小时前
React超长文本域中实现“返回顶部”浮动按钮
前端·javascript·react.js
gs801408 小时前
解构 Cordis:面向“时空可组合性”的 TypeScript 元框架深度剖析
前端·javascript·typescript