[英]jQuery - lightbox stay and page scroll
How can i create a lightbox that will always stay in const height and width of my document, and when i scroll the page behind, ligthbox don't move and page is scrolling? 如何创建一个始终保持文档高度和宽度不变的灯箱,当我向后滚动页面时,ligthbox不会移动并且页面正在滚动? I had one css that shows me a lightbox when i click on link:
我有一个CSS,当我点击链接时会向我显示一个灯箱:
function resizeLightbox() {
var overlay = createOverlay(),
lightbox = createLightbox();
overlay.css({
"width": doc.width(),
"height": doc.height()
});
var width = lightbox.outerWidth(),
height = lightbox.outerHeight();
lightbox.css({
"position": "fixed",
"width": width,
"height": height,
"top": ***, // i remove that
"left": *** // and that
});
}
.lightbox__lightbox {
display: none;
background: #fff url(../gallery/ring.gif) center center no-repeat;
z-index: 10000;
// added sth like this:
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto auto;
}
Yeah i found mistake, the problem is in top and left properties, how can i dynamic count a middle of my screen?? 是的,我发现了错误,问题出在顶部和左侧属性中,如何动态计算屏幕中间?
I need to write a function to count a middle of my screen " *** " 我需要编写一个函数来计数屏幕的中间位置“ ***”
just add position: fixed; 只需添加位置:固定; to the css of lightbox
到灯箱的CSS
lightbox.css({
"position":'fixed',
"width": width,
"height": height,
"top": (win.height() / 2) - (height / 2) + doc.scrollTop(),
"left": (win.width() / 2) - (width / 2) + doc.scrollLeft()
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.