CSS 图像查看器 - 对齐屏幕中心
我想使用下面的图像放大器/查看器,但我希望放大图像的弹出窗口出现在屏幕中央。
http://www.dynamicdrive.com/style/csslibrary/item/css_smart_image_enlarger/< /a>
我尝试了很多方法,但没有成功......
对此的任何帮助将不胜感激。
I want to use the below image enlarger/viewer but i would like the popup of the enlarged image to appear on the center of the screen.
http://www.dynamicdrive.com/style/csslibrary/item/css_smart_image_enlarger/
I tried many ways but was unsuccessful....
Any help on this would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了解决这些问题,我通常使用 JavaScript 查询 DOM 以找出窗口的大小。然后我使用:
弹出窗口的定位必须在 CSS 中设置为“绝对”。为了获得高度(与宽度相同),我使用:
如果你的 div 没有 id,你仍然可以将对象引用传递给 JavaScript 函数,例如:
并且,在附近的一段代码中:
也就是说,而不是查询 DOM要通过 ID 获取对象,可以直接将对象传递给 JavaScript 函数。
To solve these issues I usually query the DOM with JavaScript to find out the size of the window. I then use:
The positioning of the popup must be set to 'absolute' in the CSS. To get height (same for width) I use:
If your div doesn't have an id you can still pass the object reference to the JavaScript function like:
And, in a nearby piece of code:
That is, instead of querying the DOM to get the object by the ID, you directly pass the object to the JavaScript function.
如果你修复了..popup
{, 你可以这样做
位置:绝对;
宽度:140px;
左边距:-70px;
顶部:0px;
左:50%;
}
You could do like this if you got a fixed with..
.popup {
position: absolute;
width: 140px;
margin-left: -70px;
top: 0px;
left: 50%;
}