您的位置:首页 > 教育 > 锐评 > el-menu弹出菜单样式不生效

el-menu弹出菜单样式不生效

2024/10/6 20:28:20 来源:https://blog.csdn.net/qq_38436431/article/details/140553172  浏览:    关键词:el-menu弹出菜单样式不生效

1. 使用 ruoyi 项目时出现的问题。

<template><el-menu:default-active="activeMenu":collapse="false":unique-opened="true"class="container":collapse-transition="true"mode="horizontal"><sidebar-itemv-for="(route, index) in sidebarRouters":key="route.path  + index":item="route":base-path="route.path"/></el-menu></template>

class=“container” 中的样式是这样的

 .container {box-shadow: 0px 1px 4px 0px rgba(0,0,0,0.1);float: left;height:  100%;width: 200px;background-color: transparent !important;overflow: hidden;-webkit-transition: width .28s;transition: width 0.28s;-webkit-box-shadow: 2px 0 6px rgba(0,21,41,.35);box-shadow: 2px 0 6px rgba(0,21,41,.35);.svg-icon {margin-right: 10px;margin-left: 3px;}// menu hover.el-submenu__title {font-size: 17px;color: white !important;&:hover {background-color: transparent !important;}}}

2. 问题描述

  • .svg-icon 这个 样式只对 一级菜单 “高速公路” 生效! 二级菜单和 其中的选项则不能生效!

在这里插入图片描述

2. 解决方法

  • html 文档中 是没有 弹出菜单项(出入口收费站 -> 总流量 。。。)的。
    在这里插入图片描述
  • 他们在 html 文档的末尾可以看到
    在这里插入图片描述
  • 所以 根据 弹出菜单出现的位置 设置样式就可以了!在 el-menu–popup这个样式的基础上作修改
.el-menu--popup {.el-submenu__title{background-color: #0B1423 !important;color: #FFF !important;}.el-menu-item{background-color: #0B1423 !important;color: #FFF !important;}.el-menu-item:hover {background-color: #FFF !important;color: #0B1423 !important;}.el-menu-item.is-active {background-color: #FFF !important;color: #0B1423 !important;}.svg-icon {margin-right: 10px;margin-left: 3px;}  
}

4. 总结

修改弹出框元素 不在 el-menu 样式中,我们 需要在 el-menu–popup 中修改样式!

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com