【发布时间】:2017-06-09 21:57:36
【问题描述】:
如何创建一个始终保持文档高度和宽度不变的灯箱,并且当我滚动后面的页面时,灯箱不移动并且页面正在滚动?当我点击链接时,我有一个 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;
}
是的,我发现了错误,问题出在顶部和左侧属性中,我如何动态计算屏幕中间?
我需要编写一个函数来计算屏幕中间的“***”
【问题讨论】:
-
当询问有关代码引起的问题的问题时,如果您提供人们可以用来重现问题的功能示例,您将获得更好的答案。见:How to create a Minimal, Complete, and Verifiable example。谢谢!
-
谢谢,但实际上这很难,因为我的灯箱有 200 行,我不想在这里全部粘贴:/ 而且我只是不知道如何冻结我的灯箱窗口 :(
标签: javascript jquery html css