我有一个包含不同元素的html页面,我想添加一个带有一种透明效果的div来隐藏我页面的内容。 我试图将整个页面包裹在一个div中,就在身体后面有以下css
<body>
<div style="position:relative;width:100%;height:100%;
background-color:red;z-index:9999999">
</div>
</body>
有人可以帮忙吗?
答案 0 :(得分:0)
更改位置:相对于位置:固定或位置:绝对并添加:
top:0;
left:0;
bottom:0;
right:0;
答案 1 :(得分:0)
这样的东西?
#modal{width:100%;height:100%;position:absolute;top:0px;left:0px;z-index:1000;background-color:grey;opacity:.8;display:none;}
&#13;
<div id="modal">modal window<button onclick="document.getElementById('modal').style.display='none'">Close</button></div>
<div id ="Mainwindow">content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content </div><button onclick="document.getElementById('modal').style.display='block'">Display modal</button>
&#13;