将所有背景更改为透明
change all background to transparent
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";
}
我有这个 link 将所有背景更改为白色不透明度 0.4 除了背景颜色为红色的#main
问:我想在 sidenav 打开时将#main 背景更改为 rgba(0,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)';
}
关闭后会变回红色。
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";
}
我有这个 link 将所有背景更改为白色不透明度 0.4 除了背景颜色为红色的#main
问:我想在 sidenav 打开时将#main 背景更改为 rgba(0,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)';
}
关闭后会变回红色。