背景: 菜单hover就出现二级菜单,把二级菜单的背景色设置成透明的
问题:单纯使用::v-deep或者:deep修改菜单背景色,结果一直是白色,并不透明。
注意:自己调试查找元素,看具体是哪一个html元素。
html代码
<el-menu
:default-active="$route.fullPath"
mode="horizontal"
:ellipsis="false"
@select="handleSelect"
background-color="transparent" // 设置成透明色
text-color="#fff"
active-text-color="#e6a23c"
class="w-1400px m-auto"
></el-menu>
css代码
// 去掉scoped
<style lang="scss">
:root {
--el-bg-color-overlay: rgba(255, 255, 255, 0.5); /* 设为你想要的透明背景 */
--el-border-color-light: transparent; /* 设为透明或其他颜色 */
}
.el-menu--horizontal {
border-bottom: none !important;
}
::v-deep .el-popper.is-light {
background: transparent !important; /* 设为透明或其他你需要的颜色 */
border: none !important;
}
<style>