简体   繁体   English

Facebook图库/灯箱-加载时居中图像

[英]Facebook gallery/lightbox - centred image while loading

Does Facebook in its gallery put image width and height in database? Facebook在其图库中是否将图像的宽度和高度放入数据库中?

Using JavaScript, they can not be sure about image width and height until image fully loads. 使用JavaScript,他们无法确定图像的宽度和高度,直到图像完全加载为止。 But on FB, image is been loaded while its displaying and image is properly centered horizontally and vertically. 但是在FB上,在显示图像时加载了图像,并且图像在水平和垂直方向上正确居中。

Facebook use display:inline-block for the image and text-align:center for parent div to center image in theater images. Facebook将display:inline-block用于图像,将text-align:center用于父级div将剧院图像中的图像居中。 Check out their blog post that explained how they did it. 查看他们的博客文章 ,其中解释了他们的工作方式。 It's a nice CSS code but not all CSS. 这是一个不错的CSS代码,但不是全部CSS。 They use JS to set line-height of one of divs based on window.height . 他们使用JS根据window.height设置div之一的line-height

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

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