简体   繁体   English

如何正确居中Facebox Ajax请求?

[英]how to center a facebox ajax request properly?

My wordpress template uses facebox to display portfolio images via ajax requests. 我的wordpress模板使用Facebox通过Ajax请求显示投资组合图像。

The problem is the images load in different positions depending on the viewers screen size. 问题是图像会根据查看器的屏幕大小而在不同位置加载。

My template uses 我的模板使用

$('#facebox').css({
    top:    getPageScroll()[1] + (getPageHeight() / 10),
    left:   385.5
  }).show()

The facebox site uses facebox网站使用

$('#facebox').css({
   top: getPageScroll()[1] + (getPageHeight() / 10),
   left: $(window).width() / 2 - 205
 }).show() 

The facebox site displays images perfectly but when I use the same line with my template is doesn't display properly. facebox网站可以完美显示图像,但是当我在模板中使用同一行时,它无法正确显示。

Can someone point me in the right direction for getting the images to load consistently in the center of the screen? 有人可以指出我正确的方向,以使图像一致地加载到屏幕中央吗?

Link to the portfolio site im trying to fix 链接到要修复的投资组合网站

Link to the facebox site 链接到Facebox网站

Formula is: (window.width / 2) - (target.width / 2) 公式为:(window.width / 2)-(target.width / 2)

$('#facebox').css({
   top: getPageScroll()[1] + (getPageHeight() / 10),
   left: ($(window).width() / 2) - ($('#facebox').outerWidth() / 2)
 }).show() 

Note, your facebox.css sets the div#facebox to 710px width, though your images are wider. 请注意,尽管您的图像更宽,但是facebox.css会将div#facebox设置为710px宽度。 I used outerWidth() instead of width(), but not sure if that accounts properly for the css 710px width. 我使用outerWidth()而不是width(),但是不确定这是否能正确说明css 710px的宽度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM