本文介绍了在弹出图像上显示上一个和下一个图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在下一张和上一张上弹出图片。不幸的是,图标仍然留在弹出的图像后面。我已经设置了Z-index,但它仍然保持弹出状态。
html:
< div class =row-fluid>
< div class =col-sm-12>
< ul class =image-list>
< li>< img src =photos / g1.jpgalt =Photo number 1class =img-responsive img-thumbnailonclick =view(this.src)/> < /锂>
< li>< img src =photos / g2.jpgalt =Photo number 2class =img-responsive img-thumbnailonclick =view(this.src)/> < /锂>
< / ul>
< div class =navigationid =nav>
< span class =next glyphicon glyphicon-arrow-rightid =nextonclick =next()>< / span>
< / div>
< / div>
< / div>
css
.pup
{
width:100%;身高:100%;
背景:#666;
不透明度:0.7;
位置:固定;
top:0px; left:0px;
z-index:111;
display:none;
}
.viewer {
背景:#666;填充:12px;
位置:固定; z-index:222;
text-align:center;
display:none;
}
#nav {
display:none;
背景:红色;
z-index:333;
颜色:#FFF;
}
javscript
函数视图(src)
{
var viewer = document.getElementById(viewer);
viewer.innerHTML ='< img src =''+ src +'id =img/>';
var img = document.getElementById(img);
var iw = 0,ih = 0;
var dw = 0,dh = 0;
img.onload = function(){
document.getElementById(ov)。style.display =block;
viewer.style.display =block;
document.getElementById(nav)。style.display =block;
iw = viewer.offsetWidth;
ih = viewer.offsetHeight;
dw = window.innerWidth;
dh = window.innerHeight;
viewer.style.top = parseInt(dh / 2-ih / 2)+px;
viewer.style.left = parseInt(dw / 2-iw / 2)+px;
};
}
函数hide2()
{
document.getElementById(viewer)。style.display =none;
document.getElementById(ov)。style.display =none;
document.getElementById(nav)。style.display =none;
解决方案
尝试给 position:fixed
,而不是尝试给 position:absolute
。这可以很容易地使用CSS完成。看看这段代码: