行内style的权重大于内部style,所以你想要将一个块隐藏起来,并且在点击时让它出来或者隐藏,建议你使用内部样式表,如果我说的不对,还请你指出,谢谢
点击的时候 dom.style.display="xxx"就行了
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!--
display盒子进行隐藏,none用于隐藏,block用于恢复盒子
-->
<style>
.nav {
width: 300px;
height: 300px;
background-color: aquamarine;
display: none;
}
.qwe {
width: 300px;
height: 300px;
background-color: blueviolet;
}
</style>
</head>
<body>
<div class="nav"></div>
<div class="qwe"></div>
</body>
</html>