IFRAME background-color

本文介绍了如何在Internet Explorer浏览器中解决iframe背景透明的问题。通过设置allowtransparency属性为true,可以使iframe在Firefox、Safari及IE等浏览器中正常显示透明背景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在firfox,safari中,此属性设置有效,但是在IE下没有作用。其实只要:

<iframe src="..." allowtransparency="true"></iframe>

 

就可以在IE下工作。

ul.head{ border-style: groove; position: fixed; top:0; width:99%; list-style-type: none; margin-top:0; padding-left: 0px; /*创建一个新的BFC*/ overflow: hidden; background:indianred; border-radius:8px;/*圆角边框*/ font-size:18px; } li a{ /* !*实现横向导航栏, display:inline;也可,如果你想链接到具有相同的大小,你必须使用浮动的方法*!*/ float:left; height:20px; text-align: center; color: white; background-color: darksalmon; padding: 12px 20px; text-decoration: none; } li a:hover{ background-color: coral; color: black; } body{ background-attachment: fixed; background-image: url(../resources/image/blue_pink.jpg); background-size:100%; } iframe{ height:300px; width:400px; float:right; } select{ font-size: 20px; color:olive; background-color:cornsilk; } div{ margin-top:60px; } input{font-size: 16px;} button { border-radius:5px;/*圆角边框*/ font-size: 18px; background-color: #4CAF50; color: white; cursor: pointer; transition: background-color 0.3s ease; } #pauseBtn{ position:absolute; bottom:17%; left:40%; } #startBtn{ position:absolute; bottom:59%; left:15%; } #increase-btn1 { position:absolute; left: 17%; bottom:9%; } #decrease-btn1 { position:absolute; left: 19%; bottom:9%; } #increase-btn2 { position:absolute; right: 19%; bottom:25%; } #decrease-btn2 { position:absolute; right: 17%; bottom:25%; } #speedRange{ position:absolute; bottom:17%; left:50%; } button:hover { background-color: #3e8e41; } #introduction{ margin-top: 20px; width:300px; border-style: groove; font-size: 14px; color:darkred; overflow: auto; min-height:300px; max-height:300px; } footer{ position:absolute; bottom:0; width:100%; height:30px; text-align: center; } #canvas{ /*width: 880px;*/ /*height: 440px;*/ width: 100%; height: 100%; /*margin: -210px auto;*/ /*border: 2px solid yellowgreen;*/ /*display: block;*/ overflow: scroll; } .container { height: 440px; width: 880px; margin: -225px auto; border: 2px solid yellowgreen; /*display: block;*/ box-sizing:border-box; overflow: scroll; } #log{ border:2px palegoldenrod; position:absolute; top:9%; right:0.5%; background-color:lightyellow; height: 430px; /* 设置固定高度 */ width: 310px; /* 设置固定宽度 */ font-size: 16px; /* 设置默认字体大小 */ resize: none; /* 其他样式属性 */ } .red-text { color: red; }
06-01
<!DOCTYPE html> <html lang="zh-CN"> <style> /* 全局样式 */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; background-color: #f7eaea; color: #333; text-align: center; padding: 20px; } header h1 { font-size: 2em; color: #ff6b6b; margin-bottom: 20px; } .card { background-color: white; border-radius: 10px; padding: 20px; max-width: 400px; margin: auto; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .profile-pic { width: 100%; border-radius: 50%; margin-bottom: 20px; } button { background-color: #ff6b6b; color: white; border: none; padding: 10px 20px; cursor: pointer; border-radius: 5px; transition: all 0.3s ease-in-out; } button:hover { background-color: #ff4d4d; } </style> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>母亲节快乐</title> <link rel="stylesheet" href="styles.css"> </head> <body> <header> <h1>祝妈妈母亲节快乐 ❤️</h1> </header> <main> <section class="card"> <img src="mother.jpg" alt="妈妈的照片" class="profile-pic"> <p>亲爱的妈妈:</p> <p>感谢您一直以来的关爱和支持。</p> <button id="playVideo">播放祝福视频</button> </section> <section class="video-container" style="display:none;"> <iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe> </section> </main> <footer> <p>© 2023 母亲节特别献礼</p> </footer> <script src="srcipt.js"></script> </body> </html> </body> </html>把妈妈的照片和播放视频改为爱心播放
05-12
<template> <nav class="site-navbar" :class="'site-navbar--' + navbarLayoutType" id="navbar" style="height:38px;" > <!-- 背景颜色#FF7F00 rgba(126, 203, 252, 1) --> <div class="site-navbar__body clearfix" style="height:38px;margin-left:0px;background-color:rgb(13, 143, 224)"> <el-menu class="site-navbar__menu" mode="horizontal" style="height:38px;"><!-- background-color:#409EFF;width:230px; --> <el-menu-item v-if="sidebarIsShow" class="site-navbar__switch" id="myzhedie" index="0" @click="sidebarFold = !sidebarFold" style="width:64px;"> <icon-svg name="zhedie"></icon-svg> </el-menu-item> <el-menu-item v-else class="site-navbar__switch" index="0" id="myhome1" style="width:64px;"> <icon-svg name="home"></icon-svg> </el-menu-item> <!-- @click="openHomeHandle" --> <el-menu-item class="site-navbar__switch" index="0" style="padding:0 0px;background-color:transparent;color:inherit;margin-left:-10px"> <img src="~@/assets/img/logoNew6.png" style="width:160px;height:28px;"> </el-menu-item> </el-menu> <el-menu id="myNavbar" :default-active="activeMenu" @select="handleSelect" class="site-navbar__menu" mode="horizontal" style="margin-left:21px;" default-active="home"> <!-- <el-menu-item class="site-navbar__switch" index="0" @click="$router.push({ name: 'home' })"> --> <!-- <img src="~@/assets/img/logoNew5.png" style="width:160px;margin-top:1px">  --> <!-- font-style: italic; --> <!-- <span style="font-size:22px;"><font color="#db9e3f" style="font-weight: bold;font-style: normal;">欣动能源</font></span> --> <!-- </el-menu-item> --> <!-- openSideMenusHandle () $router.push({ name: 'home' }) traditionMenuHandle--> <!-- '31,118,150,153,214' --> <!-- openSideMenusHandle('31,118,150,153,214,1,46,32,67,-1') 里面的数字是父类为0的菜单ID(menu_id),即在此点击后显示 --> <!-- @click="openHomeHandle" --> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:monitornavbar')" style="margin-left:-1%;font-size: 14px;" index="home" @click="openHomeHandle"> <icon-svg name="chezidingyi" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">实时查询</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:traditionnavbar')" style="margin-left:-1%;font-size: 14px;" index="tradition" @click="openSideMenusHandle('31,118,150,153,214,1,46,32,67,-100')"> <icon-svg name="system" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">数据管理中心</span> </el-menu-item> <!-- <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:reportnavbar')" style="margin-left:-1%;font-size: 14px;" index="report" @click="openSideMenusHandle('330,339,341,429,-2')"> <icon-svg name="tubiao" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">数据中心1</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:statisticsnavbar')" style="margin-left:-1%;font-size: 14px;" index="statistics" @click="openSideMenusHandle('400,404,-1')"> <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">安全中心1</span> </el-menu-item> --> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:reportnavbar')" style="margin-left:-1%;font-size: 14px;" index="report" @click="openSideMenusHandle('445,453,458,459,462,-2')"> <icon-svg name="tubiao" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">统计分析</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:statisticsnavbar')" style="margin-left:-1%;font-size: 14px;" index="statistics" @click="openSideMenusHandle('465,470,471,475,-1')"> <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">安全中心</span> </el-menu-item> <!-- openSideMenusHandle('118,150,214,1,-3') --> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:managenavbar')" style="margin-left:-1%;font-size: 14px;" index="manage" @click="openSideMenusHandle('405,384,1,-3')"> <icon-svg name="config" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">管理中心</span> </el-menu-item> <el-submenu id="myWindow" v-if="isAuth('battery:bmsbatteryinfo:largescreennavbar')" style="margin-left:-1%;font-size: 14px;" index="largescreen"> <template slot="title" style="margin-left:-1%;font-size: 14px;"> <icon-svg name="dashujukeshihua" class="site-sidebar__menu-icon"></icon-svg> <span slot="title" style="margin-left:-1%;font-size: 14px;">驾驶舱</span> </template> <el-menu-item index="2-1" @click="openEchartInNewWindow" v-if="isAuth('mqtt:mtbatteryinfolastest:largedep')"> <icon-svg name="dashujukeshihua" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">欣动电池大屏</span> </el-menu-item> <!-- <el-menu-item index="2-2">选项2</el-menu-item> <el-menu-item index="2-3">选项3</el-menu-item> <el-submenu index="2-4"> <template slot="title">选项4</template> <el-menu-item index="2-4-1">选项1</el-menu-item> <el-menu-item index="2-4-2">选项2</el-menu-item> <el-menu-item index="2-4-3">选项3</el-menu-item> </el-submenu> --> </el-submenu> </el-menu> <el-menu class="site-navbar__menu site-navbar__menu--right" mode="horizontal"> <!-- @click="$router.push({ name: 'echart' })" --> <el-menu-item index="1" id="mydaping" @click="openEchartInNewWindow" v-if="isAuth('mqtt:mtbatteryinfolastest:largeDatalist')"> <template slot="title"> <el-badge value="大屏"> <icon-svg name="dashujukeshihua" class="el-icon-rank"></icon-svg> </el-badge> </template> </el-menu-item> <el-menu-item index="2" id="myshezhi" @click="$router.push({ name: 'theme' })"> <template slot="title"> <el-badge value="设置"> <icon-svg name="shezhi" class="el-icon-setting"></icon-svg> </el-badge> </template> </el-menu-item> <!-- <el-menu-item index="2"> <el-badge value="hot"> <a href="https://www.renren.io/" target="_blank" rel="noopener noreferrer">官方社区</a> </el-badge> </el-menu-item> <el-submenu index="3"> <template slot="title">Git源码</template> <el-menu-item index="2-1"><a href="https://github.com/renrenio/renren-fast-vue" target="_blank" rel="noopener noreferrer">前端</a></el-menu-item> <el-menu-item index="2-2"><a href="https://gitee.com/renrenio/renren-fast" target="_blank" rel="noopener noreferrer">后台</a></el-menu-item> <el-menu-item index="2-3"><a href="https://gitee.com/renrenio/renren-generator" target="_blank" rel="noopener noreferrer">代码生成器</a></el-menu-item> </el-submenu> --> <el-menu-item class="site-navbar__avatar" index="3" id="myhuichu"> <el-dropdown :show-timeout="0" placement="bottom"> <span class="el-dropdown-link"> <img src="~@/assets/img/avatar1.png" style="width:30px;height:30px;margin-bottom:2px;" :alt="userName">{{ userName }} </span> <el-dropdown-menu slot="dropdown"> <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item> <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item> </el-dropdown-menu> </el-dropdown> </el-menu-item> </el-menu> </div> <!-- 弹窗, 修改密码 --> <update-password v-if="updatePassowrdVisible" ref="updatePassowrd"></update-password> </nav> </template> <script> import UpdatePassword from './main-navbar-update-password' import { clearLoginInfo,EventBus } from '@/utils' import Router from 'vue-router' import http from '@/utils/httpRequest' import { isURL } from '@/utils/validate' export default { data () { return { firstLogin: true, updatePassowrdVisible: false, activeMenu: 'tradition' // 默认激活的菜单项ID } }, components: { UpdatePassword }, computed: { navbarLayoutType: { get () { return this.$store.state.common.navbarLayoutType } }, sidebarFold: { get () { return this.$store.state.common.sidebarFold }, set (val) { this.$store.commit('common/updateSidebarFold', val) } }, mainTabs: { get () { return this.$store.state.common.mainTabs }, set (val) { this.$store.commit('common/updateMainTabs', val) } }, menuActiveName: { get () { return this.$store.state.common.menuActiveName }, set (val) { this.$store.commit('common/updateMenuActiveName', val) } }, userName: { get () { return this.$store.state.user.name } }, isHomePage(){ return this.$route.path === '/home' }, // 左侧菜单显示 sidebarIsShow: { get () { return this.$store.state.common.sidebarIsShow }, set (val) { this.$store.commit('common/updateSidebarIsShow', val) } }, // 顶部菜单的点击 // activeMenuIndex() { // return this.activeMenu.toString(); // 转换为字符串,以匹配模板中的index // } }, created() { // 刚登录进来,多点击监控中心,防止左侧缓存的菜单出现---20241217 this.firstLogin && ---------------------------------- if(localStorage.getItem('firstLogin')===null){ localStorage.clear(); console.log('本地存储已清除'); localStorage.setItem('firstLogin', '1'); this.firstLogin = false; // alert('第一次进来,firstLogin='+localStorage.getItem('firstLogin')) // 显示左侧菜单隐藏 this.openHomeHandle () setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 1); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 100); }else{ // 显示左侧菜单显示 // alert('firstLogin='+localStorage.getItem('firstLogin')) // this.$store.state.common.sidebarIsShow = true } //------------------------------------------------------------------------------------------------------------ this.openHomeHandle () setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 10); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 100); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 120); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 180); // 页面加载时尝试恢复之前的选中状态。刷新时一直保持点击颜色 this.activeMenu = sessionStorage.getItem('activeMenu') || this.activeMenu; }, methods: { handleSelect(key, keyPath) { // 菜单项被点击时保存选中状态 sessionStorage.setItem('activeMenu', key); // vue刷新页面数据不丢失-localStorage或sessionStorage保存数据 }, openEchartInNewWindow() { const routeData = this.$router.resolve({ name: 'echart' }); window.open(routeData.href, '_blank'); }, // 修改密码 updatePasswordHandle () { this.updatePassowrdVisible = true this.$nextTick(() => { this.$refs.updatePassowrd.init() }) }, // 退出 logoutHandle () { this.$confirm(`确定进行[退出]操作?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { this.$http({ url: this.$http.adornUrl('/sys/logout'), method: 'post', data: this.$http.adornData() }).then(({data}) => { if (data && data.code === 0) { clearLoginInfo() this.$router.push({ name: 'login' }) } }) }).catch(() => {}) }, openSideMenusHandle (parentMenuIds) { // alert(parentMenuIds) this.mainTabs = [] //清除打开的tab菜单 this.menuActiveName = '' // 左侧菜单显示 this.$store.state.common.sidebarIsShow = true // 折叠打开 this.$store.state.common.sidebarFold = false // 这里调用左侧菜单的方法 EventBus.$emit('callMethod',parentMenuIds); // 再次调用,防止点击监控中心--然后跳转到其他菜单时无反应 setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 150); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 100); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 220); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 120); // this.$router.push({ name: 'center' }) // center home }, openHomeHandle () { // alert("jianko") // this.mainTabs = [] //清除打开的tab菜单 // this.menuActiveName = '' // this.isHomePage = true // 折叠关闭 this.$store.state.common.sidebarFold = true // 左侧菜单显示关闭 this.$store.state.common.sidebarIsShow = false this.$router.push({ name: 'home' }) }, //--------------------------------------------------------------------------------------------------- // tabs, 关闭全部tab tabsCloseAllHandle () { this.mainTabs = [] this.menuActiveName = '' this.$router.push({ name: 'home' }) }, reloadMenus(parentMenuIds){ this.$http({ url: this.$http.adornUrl('/sys/menu/navappoint'), method: 'get', // params: this.$http.adornParams() params: this.$http.adornParams({ 'parentMenuIds': parentMenuIds }) }).then(({data}) => { if (data && data.code === 0) { // alert("获取导航菜单成功") this.fnAddDynamicMenuRoutes(data.menuList) this.$router.options.isAddDynamicMenuRoutes = true sessionStorage.setItem('menuList', JSON.stringify(data.menuList || '[]')) sessionStorage.setItem('permissions', JSON.stringify(data.permissions || '[]')) // sessionStorage.setItem('menuList', '[]') // sessionStorage.setItem('permissions', '[]') // alert("添加菜单") // 这里调用左侧菜单的方法 EventBus.$emit('callMethod',parentMenuIds); this.tabsCloseAllHandle (); // 折叠打开 this.$store.state.common.sidebarFold = false this.$router.push({ name: 'home' }) // next({ ...to, replace: true }) // 刷新 // location.reload() // alert("前往首页") } else { sessionStorage.setItem('menuList', '[]') sessionStorage.setItem('permissions', '[]') // 折叠缩进 this.$store.state.common.sidebarFold = true next() } }).catch((e) => { // alert("请求菜单列表和权限失败-to.path="+to.path) console.log(`%c${e} 请求菜单列表和权限失败,跳转至登录页!!`, 'color:blue') // alert("权限失败login") // this.$router.push({ name: 'login' }) }) }, /** * 添加动态(菜单)路由 * @param {*} menuList 菜单列表 * @param {*} routes 递归创建的动态(菜单)路由 */ fnAddDynamicMenuRoutes (menuList = [], routes = []) { var temp = [] for (var i = 0; i < menuList.length; i++) { if (menuList[i].list && menuList[i].list.length >= 1) { temp = temp.concat(menuList[i].list) } else if (menuList[i].url && /\S/.test(menuList[i].url)) { menuList[i].url = menuList[i].url.replace(/^\//, '') var route = { path: menuList[i].url.replace('/', '-'), component: null, name: menuList[i].url.replace('/', '-'), meta: { menuId: menuList[i].menuId, title: menuList[i].name, isDynamic: true, isTab: true, iframeUrl: '' } } // url以http[s]://开头, 通过iframe展示 if (isURL(menuList[i].url)) { route['path'] = `i-${menuList[i].menuId}` route['name'] = `i-${menuList[i].menuId}` route['meta']['iframeUrl'] = menuList[i].url } else { try { route['component'] = _import(`modules/${menuList[i].url}`) || null } catch (e) {} } routes.push(route) } } if (temp.length >= 1) { this.fnAddDynamicMenuRoutes(temp, routes) } else { var mainRoutes = { name: 'main-dynamic', children: routes, path: '/' } // mainRoutes.name = 'main-dynamic' // mainRoutes.children = routes this.$router.addRoutes([ mainRoutes, { path: '*', redirect: { name: '404' } } ]) sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]')) console.log('\n') console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue') console.log(mainRoutes.children) console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue') } }, /** * 添加动态(菜单)路由 * @param {*} menuList 菜单列表 * @param {*} routes 递归创建的动态(菜单)路由 */ fnAddDynamicMenuRoutes2 (menuList) { var routes = [] var temp = [] // alert("添加动态(菜单)路由--"+menuList.length) for (var i = 0; i < menuList.length; i++) { // alert("添加动态URL----"+menuList[i].url) if (menuList[i].list && menuList[i].list.length >= 1) { temp = temp.concat(menuList[i].list) } else if (menuList[i].url && /\S/.test(menuList[i].url)) { menuList[i].url = menuList[i].url.replace(/^\//, '') var route = { path: menuList[i].url.replace('/', '-'), component: null, name: menuList[i].url.replace('/', '-'), meta: { menuId: menuList[i].menuId, title: menuList[i].name, isDynamic: true, isTab: true, iframeUrl: '' } } // alert("添加动态=isTab==="+route['meta']['isTab']) // url以http[s]://开头, 通过iframe展示 if (isURL(menuList[i].url)) { route['path'] = `i-${menuList[i].menuId}` route['name'] = `i-${menuList[i].menuId}` route['meta']['iframeUrl'] = menuList[i].url // alert("添加动态=isTab==="+route['meta']['isTab']) } else { try { route['component'] = _import(`modules/${menuList[i].url}`) || null } catch (e) {} } routes.push(route) } } if (temp.length >= 1) { this.fnAddDynamicMenuRoutes(temp, routes) } else { var mainRoutes = { name: 'main-dynamic', children: routes, path: '/' } // mainRoutes.name = 'main-dynamic' // mainRoutes.children = routes this.$router.addRoutes([ mainRoutes, { path: '*', redirect: { name: '404' } } ]) sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]')) console.log('\n') console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue') console.log(mainRoutes.children) console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue') } } //---------------------------------------------------------------------------------------------------------------------- } } </script> <style> #myNavbar .el-menu-item:hover { background-color: transparent !important; color: inherit !important; } /* 顶部菜单点击后的背景颜色 */ #myNavbar .el-menu-item.is-active { background-color:rgb(15, 89, 164) !important; color:rgb(235, 184, 17); /*选中颜色*/ span { color: #fff !important; } } /* 驾驶舱鼠标悬浮时 样式文件或组件内样式 */ #myNavbar .el-submenu__title:hover { background-color:rgb(15, 89, 164) !important; /* 使用!important确保覆盖默认样式 */ } .site-navbar__menu .el-menu-item, .site-navbar__menu .el-submenu > .el-submenu__title { height: 38px; line-height: 38px; } /* 左侧菜单选中与悬停样式 */ #myzhedie:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myzhedie.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myhome1:hover { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myhome1.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myshezhi:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myshezhi.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #mydaping:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #mydaping.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myhuichu:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myhuichu.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } /* 加载表头颜色设置 */ /* rgba(126, 203, 252, 1) rgba(211, 236, 255, 255) #cdccd9 #87CEEB; rgba(211, 236, 255, 255); rgba(137, 207, 240); */ /* .el-table thead th { color: #909399; background-color: rgba(211, 236, 255, 255); font-weight: 800; color: #1D3124; } */ </style>修改驾驶舱下拉框的背景颜色和当前菜单颜色风格一致
最新发布
07-23
<template> <nav class="site-navbar" :class="'site-navbar--' + navbarLayoutType" id="navbar" style="height:38px;" > <!-- 背景颜色#FF7F00 rgb(9, 153, 243) --> <div class="site-navbar__body clearfix" style="height:38px;margin-left:0px;background-color:rgb(9, 153, 243)"> <el-menu class="site-navbar__menu" mode="horizontal" style="height:38px;"><!-- background-color:rgb(9, 153, 243) ;width:230px; --> <el-menu-item v-if="sidebarIsShow" class="site-navbar__switch" id="myzhedie" index="0" @click="sidebarFold = !sidebarFold" style="width:64px;"> <icon-svg name="zhedie"></icon-svg> </el-menu-item> <el-menu-item v-else class="site-navbar__switch" index="0" id="myhome1" style="width:64px;"> <icon-svg name="home"></icon-svg> </el-menu-item> <!-- @click="openHomeHandle" --> <el-menu-item class="site-navbar__switch" index="0" style="padding:0 0px;background-color:transparent;color:inherit;margin-left:-10px"> <img src="~@/assets/img/logoNew6.png" style="width:160px;height:28px;"> </el-menu-item> </el-menu> <el-menu id="myNavbar" :default-active="activeMenu" @select="handleSelect" class="site-navbar__menu" mode="horizontal" style="margin-left:21px;" default-active="home"> <!-- <el-menu-item class="site-navbar__switch" index="0" @click="$router.push({ name: 'home' })"> --> <!-- <img src="~@/assets/img/logoNew5.png" style="width:160px;margin-top:1px">  --> <!-- font-style: italic; --> <!-- <span style="font-size:22px;"><font color="#db9e3f" style="font-weight: bold;font-style: normal;">欣动能源</font></span> --> <!-- </el-menu-item> --> <!-- openSideMenusHandle () $router.push({ name: 'home' }) traditionMenuHandle--> <!-- '31,118,150,153,214' --> <!-- openSideMenusHandle('31,118,150,153,214,1,46,32,67,-1') 里面的数字是父类为0的菜单ID(menu_id),即在此点击后显示 --> <!-- @click="openHomeHandle" --> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:monitornavbar')" style="margin-left:-1%;font-size: 14px;" index="home" @click="openHomeHandle"> <icon-svg name="chezidingyi" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">实时查询</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:traditionnavbar')" style="margin-left:-1%;font-size: 14px;" index="tradition" @click="openSideMenusHandle('31,118,150,153,214,1,46,32,67,-100')"> <icon-svg name="system" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">数据管理中心</span> </el-menu-item> <!-- <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:reportnavbar')" style="margin-left:-1%;font-size: 14px;" index="report" @click="openSideMenusHandle('330,339,341,429,-2')"> <icon-svg name="tubiao" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">数据中心1</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:statisticsnavbar')" style="margin-left:-1%;font-size: 14px;" index="statistics" @click="openSideMenusHandle('400,404,-1')"> <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">安全中心1</span> </el-menu-item> --> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:reportnavbar')" style="margin-left:-1%;font-size: 14px;" index="report" @click="openSideMenusHandle('445,453,458,459,462,-2')"> <icon-svg name="tubiao" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">统计分析</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:statisticsnavbar')" style="margin-left:-1%;font-size: 14px;" index="statistics" @click="openSideMenusHandle('465,470,471,475,-1')"> <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">安全中心</span> </el-menu-item> <!-- openSideMenusHandle('118,150,214,1,-3') --> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:managenavbar')" style="margin-left:-1%;font-size: 14px;" index="manage" @click="openSideMenusHandle('405,384,1,-3')"> <icon-svg name="config" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">管理中心</span> </el-menu-item> <el-submenu id="myWindow" v-if="isAuth('battery:bmsbatteryinfo:largescreennavbar')" style="margin-left:-1%;font-size: 14px;" index="largescreen"> <template slot="title" style="margin-left:-1%;font-size: 14px;"> <icon-svg name="dashujukeshihua" class="site-sidebar__menu-icon"></icon-svg> <span slot="title" style="margin-left:-1%;font-size: 14px;">驾驶舱</span> </template> <el-menu-item index="2-1" @click="openEchartInNewWindow" v-if="isAuth('mqtt:mtbatteryinfolastest:largedep')"> <icon-svg name="dashujukeshihua" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">欣动电池大屏</span> </el-menu-item> <!-- <el-menu-item index="2-2">选项2</el-menu-item> <el-menu-item index="2-3">选项3</el-menu-item> <el-submenu index="2-4"> <template slot="title">选项4</template> <el-menu-item index="2-4-1">选项1</el-menu-item> <el-menu-item index="2-4-2">选项2</el-menu-item> <el-menu-item index="2-4-3">选项3</el-menu-item> </el-submenu> --> </el-submenu> </el-menu> <el-menu class="site-navbar__menu site-navbar__menu--right" mode="horizontal"> <!-- @click="$router.push({ name: 'echart' })" --> <el-menu-item index="1" id="mydaping" @click="openEchartInNewWindow" v-if="isAuth('mqtt:mtbatteryinfolastest:largeDatalist')"> <template slot="title"> <el-badge value="大屏"> <icon-svg name="dashujukeshihua" class="el-icon-rank"></icon-svg> </el-badge> </template> </el-menu-item> <el-menu-item index="2" id="myshezhi" @click="$router.push({ name: 'theme' })"> <template slot="title"> <el-badge value="设置"> <icon-svg name="shezhi" class="el-icon-setting"></icon-svg> </el-badge> </template> </el-menu-item> <!-- <el-menu-item index="2"> <el-badge value="hot"> <a href="https://www.renren.io/" target="_blank" rel="noopener noreferrer">官方社区</a> </el-badge> </el-menu-item> <el-submenu index="3"> <template slot="title">Git源码</template> <el-menu-item index="2-1"><a href="https://github.com/renrenio/renren-fast-vue" target="_blank" rel="noopener noreferrer">前端</a></el-menu-item> <el-menu-item index="2-2"><a href="https://gitee.com/renrenio/renren-fast" target="_blank" rel="noopener noreferrer">后台</a></el-menu-item> <el-menu-item index="2-3"><a href="https://gitee.com/renrenio/renren-generator" target="_blank" rel="noopener noreferrer">代码生成器</a></el-menu-item> </el-submenu> --> <el-menu-item class="site-navbar__avatar" index="3" id="myhuichu"> <el-dropdown :show-timeout="0" placement="bottom"> <span class="el-dropdown-link"> <img src="~@/assets/img/avatar1.png" style="width:30px;height:30px;margin-bottom:2px;" :alt="userName">{{ userName }} </span> <el-dropdown-menu slot="dropdown"> <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item> <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item> </el-dropdown-menu> </el-dropdown> </el-menu-item> </el-menu> </div> <!-- 弹窗, 修改密码 --> <update-password v-if="updatePassowrdVisible" ref="updatePassowrd"></update-password> </nav> </template> <script> import UpdatePassword from './main-navbar-update-password' import { clearLoginInfo,EventBus } from '@/utils' import Router from 'vue-router' import http from '@/utils/httpRequest' import { isURL } from '@/utils/validate' export default { data () { return { firstLogin: true, updatePassowrdVisible: false, activeMenu: 'tradition' // 默认激活的菜单项ID } }, components: { UpdatePassword }, computed: { navbarLayoutType: { get () { return this.$store.state.common.navbarLayoutType } }, sidebarFold: { get () { return this.$store.state.common.sidebarFold }, set (val) { this.$store.commit('common/updateSidebarFold', val) } }, mainTabs: { get () { return this.$store.state.common.mainTabs }, set (val) { this.$store.commit('common/updateMainTabs', val) } }, menuActiveName: { get () { return this.$store.state.common.menuActiveName }, set (val) { this.$store.commit('common/updateMenuActiveName', val) } }, userName: { get () { return this.$store.state.user.name } }, isHomePage(){ return this.$route.path === '/home' }, // 左侧菜单显示 sidebarIsShow: { get () { return this.$store.state.common.sidebarIsShow }, set (val) { this.$store.commit('common/updateSidebarIsShow', val) } }, // 顶部菜单的点击 // activeMenuIndex() { // return this.activeMenu.toString(); // 转换为字符串,以匹配模板中的index // } }, created() { // 刚登录进来,多点击监控中心,防止左侧缓存的菜单出现---20241217 this.firstLogin && ---------------------------------- if(localStorage.getItem('firstLogin')===null){ localStorage.clear(); console.log('本地存储已清除'); localStorage.setItem('firstLogin', '1'); this.firstLogin = false; // alert('第一次进来,firstLogin='+localStorage.getItem('firstLogin')) // 显示左侧菜单隐藏 this.openHomeHandle () setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 1); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 100); }else{ // 显示左侧菜单显示 // alert('firstLogin='+localStorage.getItem('firstLogin')) // this.$store.state.common.sidebarIsShow = true } //------------------------------------------------------------------------------------------------------------ this.openHomeHandle () setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 10); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 100); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 120); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 180); // 页面加载时尝试恢复之前的选中状态。刷新时一直保持点击颜色 this.activeMenu = sessionStorage.getItem('activeMenu') || this.activeMenu; }, methods: { handleSelect(key, keyPath) { // 菜单项被点击时保存选中状态 sessionStorage.setItem('activeMenu', key); // vue刷新页面数据不丢失-localStorage或sessionStorage保存数据 }, openEchartInNewWindow() { const routeData = this.$router.resolve({ name: 'echart' }); window.open(routeData.href, '_blank'); }, // 修改密码 updatePasswordHandle () { this.updatePassowrdVisible = true this.$nextTick(() => { this.$refs.updatePassowrd.init() }) }, // 退出 logoutHandle () { this.$confirm(`确定进行[退出]操作?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { this.$http({ url: this.$http.adornUrl('/sys/logout'), method: 'post', data: this.$http.adornData() }).then(({data}) => { if (data && data.code === 0) { clearLoginInfo() this.$router.push({ name: 'login' }) } }) }).catch(() => {}) }, openSideMenusHandle (parentMenuIds) { // alert(parentMenuIds) this.mainTabs = [] //清除打开的tab菜单 this.menuActiveName = '' // 左侧菜单显示 this.$store.state.common.sidebarIsShow = true // 折叠打开 this.$store.state.common.sidebarFold = false // 这里调用左侧菜单的方法 EventBus.$emit('callMethod',parentMenuIds); // 再次调用,防止点击监控中心--然后跳转到其他菜单时无反应 setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 150); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 100); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 220); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 120); // this.$router.push({ name: 'center' }) // center home }, openHomeHandle () { // alert("jianko") // this.mainTabs = [] //清除打开的tab菜单 // this.menuActiveName = '' // this.isHomePage = true // 折叠关闭 this.$store.state.common.sidebarFold = true // 左侧菜单显示关闭 this.$store.state.common.sidebarIsShow = false this.$router.push({ name: 'home' }) }, //--------------------------------------------------------------------------------------------------- // tabs, 关闭全部tab tabsCloseAllHandle () { this.mainTabs = [] this.menuActiveName = '' this.$router.push({ name: 'home' }) }, reloadMenus(parentMenuIds){ this.$http({ url: this.$http.adornUrl('/sys/menu/navappoint'), method: 'get', // params: this.$http.adornParams() params: this.$http.adornParams({ 'parentMenuIds': parentMenuIds }) }).then(({data}) => { if (data && data.code === 0) { // alert("获取导航菜单成功") this.fnAddDynamicMenuRoutes(data.menuList) this.$router.options.isAddDynamicMenuRoutes = true sessionStorage.setItem('menuList', JSON.stringify(data.menuList || '[]')) sessionStorage.setItem('permissions', JSON.stringify(data.permissions || '[]')) // sessionStorage.setItem('menuList', '[]') // sessionStorage.setItem('permissions', '[]') // alert("添加菜单") // 这里调用左侧菜单的方法 EventBus.$emit('callMethod',parentMenuIds); this.tabsCloseAllHandle (); // 折叠打开 this.$store.state.common.sidebarFold = false this.$router.push({ name: 'home' }) // next({ ...to, replace: true }) // 刷新 // location.reload() // alert("前往首页") } else { sessionStorage.setItem('menuList', '[]') sessionStorage.setItem('permissions', '[]') // 折叠缩进 this.$store.state.common.sidebarFold = true next() } }).catch((e) => { // alert("请求菜单列表和权限失败-to.path="+to.path) console.log(`%c${e} 请求菜单列表和权限失败,跳转至登录页!!`, 'color:blue') // alert("权限失败login") // this.$router.push({ name: 'login' }) }) }, /** * 添加动态(菜单)路由 * @param {*} menuList 菜单列表 * @param {*} routes 递归创建的动态(菜单)路由 */ fnAddDynamicMenuRoutes (menuList = [], routes = []) { var temp = [] for (var i = 0; i < menuList.length; i++) { if (menuList[i].list && menuList[i].list.length >= 1) { temp = temp.concat(menuList[i].list) } else if (menuList[i].url && /\S/.test(menuList[i].url)) { menuList[i].url = menuList[i].url.replace(/^\//, '') var route = { path: menuList[i].url.replace('/', '-'), component: null, name: menuList[i].url.replace('/', '-'), meta: { menuId: menuList[i].menuId, title: menuList[i].name, isDynamic: true, isTab: true, iframeUrl: '' } } // url以http[s]://开头, 通过iframe展示 if (isURL(menuList[i].url)) { route['path'] = `i-${menuList[i].menuId}` route['name'] = `i-${menuList[i].menuId}` route['meta']['iframeUrl'] = menuList[i].url } else { try { route['component'] = _import(`modules/${menuList[i].url}`) || null } catch (e) {} } routes.push(route) } } if (temp.length >= 1) { this.fnAddDynamicMenuRoutes(temp, routes) } else { var mainRoutes = { name: 'main-dynamic', children: routes, path: '/' } // mainRoutes.name = 'main-dynamic' // mainRoutes.children = routes this.$router.addRoutes([ mainRoutes, { path: '*', redirect: { name: '404' } } ]) sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]')) console.log('\n') console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue') console.log(mainRoutes.children) console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue') } }, /** * 添加动态(菜单)路由 * @param {*} menuList 菜单列表 * @param {*} routes 递归创建的动态(菜单)路由 */ fnAddDynamicMenuRoutes2 (menuList) { var routes = [] var temp = [] // alert("添加动态(菜单)路由--"+menuList.length) for (var i = 0; i < menuList.length; i++) { // alert("添加动态URL----"+menuList[i].url) if (menuList[i].list && menuList[i].list.length >= 1) { temp = temp.concat(menuList[i].list) } else if (menuList[i].url && /\S/.test(menuList[i].url)) { menuList[i].url = menuList[i].url.replace(/^\//, '') var route = { path: menuList[i].url.replace('/', '-'), component: null, name: menuList[i].url.replace('/', '-'), meta: { menuId: menuList[i].menuId, title: menuList[i].name, isDynamic: true, isTab: true, iframeUrl: '' } } // alert("添加动态=isTab==="+route['meta']['isTab']) // url以http[s]://开头, 通过iframe展示 if (isURL(menuList[i].url)) { route['path'] = `i-${menuList[i].menuId}` route['name'] = `i-${menuList[i].menuId}` route['meta']['iframeUrl'] = menuList[i].url // alert("添加动态=isTab==="+route['meta']['isTab']) } else { try { route['component'] = _import(`modules/${menuList[i].url}`) || null } catch (e) {} } routes.push(route) } } if (temp.length >= 1) { this.fnAddDynamicMenuRoutes(temp, routes) } else { var mainRoutes = { name: 'main-dynamic', children: routes, path: '/' } // mainRoutes.name = 'main-dynamic' // mainRoutes.children = routes this.$router.addRoutes([ mainRoutes, { path: '*', redirect: { name: '404' } } ]) sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]')) console.log('\n') console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue') console.log(mainRoutes.children) console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue') } } //---------------------------------------------------------------------------------------------------------------------- } } </script> <style> #myNavbar .el-menu-item:hover { background-color: transparent !important; color: inherit !important; } /* 顶部菜单点击后的背景颜色 */ #myNavbar .el-menu-item.is-active { background-color: #409EFF !important; color: #fff; /*选中颜色*/ span { color: #fff !important; } } /* 驾驶舱鼠标悬浮时 样式文件或组件内样式 */ #myNavbar .el-submenu__title:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ } .site-navbar__menu .el-menu-item, .site-navbar__menu .el-submenu > .el-submenu__title { height: 38px; line-height: 38px; } /* 左侧菜单选中与悬停样式 */ #myzhedie:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myzhedie.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myhome1:hover { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myhome1.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myshezhi:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myshezhi.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #mydaping:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #mydaping.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myhuichu:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myhuichu.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } /* 加载表头颜色设置 */ /* rgba(126, 203, 252, 1) rgba(211, 236, 255, 255) #cdccd9 #87CEEB; rgba(211, 236, 255, 255); rgba(137, 207, 240); */ /* .el-table thead th { color: #909399; background-color: rgba(211, 236, 255, 255); font-weight: 800; color: #1D3124; } */ </style>在不改变原有功能逻辑的基础上,帮我优化此页面的颜色配比,顶部菜单栏使用深蓝色高对比度的颜色,侧边子菜单也要提高对比度
07-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值