0
我正在製作燈箱效果。使用GridView向用戶顯示圖像。點擊其中一個圖像後,應該在當前頁面上方顯示另一個圖層,並給出更大的圖像和描述。我設法顯示圖層及其內容的圖層,但一切都是透明的。我試圖設置不透明度爲1和移動其他元素Z-index較高,但沒有任何工程不同圖層Div燈箱效果
這裏是我的CSS代碼
#imageshown{
position:absolute;
z-index:1;
width:1000px;
height:600px;
background:#000;
opacity:0.8;
}
#imageshown > img{
opacity:1;
z-index:2;
position:relative;
top:15px;
width:450px;
height:450px;
margin:0 auto;
}
#image_content{
opacity:1;
z-index:2;
position:relative;
top:15px;
width:450px;
height:100px;
margin:0 auto;
background:#FFF;
}
#exit{
position:absolute;
border-radius:50px;
background:#006;
opacity:1;
top:-5px;
left:-5px;
z-index:2;
color:white;
text-align:center;
width:30px;
height:30px;
}
和我的jQuery代碼
$("#imggroup img").click(function(e) {
$(document).find(".NewElement").remove();
var ImageElement ="<img src=\"" + $(this).attr("src") + "\" alt=\"image shown\" />";
var DivContents = "<div id=\"image_content\"> blah blah blah </div>";
var Exit = "<div id=\"exit\" > X </div>";
var ElementWrap = "<div id=\"imageshown\" class= \"NewElement\"> "+ ImageElement + DivContents+ Exit+"</div>";
alert(ElementWrap);
$("#container").prepend(ElementWrap);
});
我有功能也可以退出,但我不能點擊它
謝謝。有效。我只是添加'background:rgba(0,0,0,0.8);' – user3265085