我的意思是我按左menu入面的按钮,div1与div2被div3覆盖,打开页面时是显示div1同div2的
1个回答
展开全部
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div onclick="showcover()" style="text-align:center;font-size:30px; line-height:100px; height:100px;
width:100%;background:Blue;color:white">MENU : Press me!</div>
<div id="div1" style="text-align:center;font-size:30px; line-height:100px; height:100px;
width:100%;background:#555;color:white">DIV ONE</div>
<div id="div2" style="text-align:center;font-size:30px; line-height:100px; height:100px;
width:100%;background:#999;color:white">DIV TWO</div>
<div id="div3" style="display:none;text-align:center;font-size:30px; line-height:200px; height:200px;
width:100%;background:#999;color:white">DIV THREE : I have covered the 1 and 2.</div>
<script>
function showcover()
{
if(document.getElementById("div3").style.display=="none")
{
document.getElementById("div1").style.display="none";
document.getElementById("div2").style.display="none";
document.getElementById("div3").style.display="block";
}
else
{
document.getElementById("div1").style.display="block";
document.getElementById("div2").style.display="block";
document.getElementById("div3").style.display="none";
}
}
</script>
</body>
</html>
直接试试这段代码,如果还不行。那么就百度hi吧。
<html>
<head>
</head>
<body>
<div onclick="showcover()" style="text-align:center;font-size:30px; line-height:100px; height:100px;
width:100%;background:Blue;color:white">MENU : Press me!</div>
<div id="div1" style="text-align:center;font-size:30px; line-height:100px; height:100px;
width:100%;background:#555;color:white">DIV ONE</div>
<div id="div2" style="text-align:center;font-size:30px; line-height:100px; height:100px;
width:100%;background:#999;color:white">DIV TWO</div>
<div id="div3" style="display:none;text-align:center;font-size:30px; line-height:200px; height:200px;
width:100%;background:#999;color:white">DIV THREE : I have covered the 1 and 2.</div>
<script>
function showcover()
{
if(document.getElementById("div3").style.display=="none")
{
document.getElementById("div1").style.display="none";
document.getElementById("div2").style.display="none";
document.getElementById("div3").style.display="block";
}
else
{
document.getElementById("div1").style.display="block";
document.getElementById("div2").style.display="block";
document.getElementById("div3").style.display="none";
}
}
</script>
</body>
</html>
直接试试这段代码,如果还不行。那么就百度hi吧。
来自:求助得到的回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询