問題這是我在這裏的第一個問題,我試圖搜索相當一段時間了,我還沒有發現任何問題與我的相同或觸及同樣的問題。更改顯示從塊到無,顯示div
我想做一個CSS彈出窗口,它有一個覆蓋整個網站的背景div和一個顯示實際內容的居中的div。
我的問題是,當我點擊應該顯示他們兩個的按鈕時,只有居中的div顯示出來。即使我註釋掉我的css文件中的display:none
- 屬性,背景div也沒有附加任何顏色或樣式。如果我用文本填充,文本顯示在網站上div應該是「假定」的,如果沒有任何樣式表附加到它。
我已經從coder的代碼中獲得了代碼this question。
這就是:
腳本:
$("#btn-update").click(function() {
document.getElementById("light").style.display="block";
document.getElementById("blackground").style.display="block";
});
HTML:
<button type="button" id="btn-update">Button!</button>
<div id="light" class="white_content">This is the lightbox content. <a href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
<div id="blackground" class="black_overlay"></div>
CSS:
.black_overlay{
/*display: none;*/
position: absolute;
top: 10%;
left: 10%;
width: 100%;
height: 100%;
background-color: #000000;
z-index:1001;
/*-moz-opacity: 0.8;*/
/*opacity:.80;*/
/*filter: alpha(opacity=80);*/
}
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 15%;
height: 15%;
padding: 16px;
border: 16px solid orange;
background-color: white;
z-index:1002;
overflow: auto;
}
Here's the fiddle-demo so you can play around as well
我試圖改變屬性,註釋出來,使得DIV可見從一開始走,但它似乎總是不能正常顯示(而white_content總是這樣)。
另外: JS小提琴有問題顯示白色內容,但是當您刪除display:none
屬性時黑色覆蓋圖顯示得很好。
非常感謝您的幫助。一直停留了一段時間了
你應該爲了使用它選擇了jQuery庫作爲框架(下拉左側)時
</head>
相同的代碼無法正常工作。 –