将所有背景更改为透明



https://codepen.io/jayllopy/pen/bQgRPY

function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
document.body.style.backgroundColor = "rgba(0,0,0,0.4)";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
document.body.style.backgroundColor = "white";
}

我有这个链接,它将所有背景更改为白色不透明度0.4,除了#main和bg颜色的红色

Q: 当侧导航打开时,我想将#主背景更改为rgba(0,0,0.4(

function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
document.getElementById("main").style.backgroundColor = 'rgba(0,0,0,0.4)';
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
document.body.style.backgroundColor = "white";
document.getElementById("main").style.backgroundColor = 'rgb(255,0,0)';
}

当你关闭它时,它会变回红色。

相关内容

  • 没有找到相关文章

最新更新