这个背景图片是如何工作的?
所以这个网站:
他们在每个页面上都有一个背景图像,但是当缩放,它永远不会改变。更不用说它的加载速度有多快了。如何在没有背景图片的情况下实现内容缩放?我可以理解这是不是重复的图像,但事实并非如此。
So This website:
They have a background image on every page but when zooming, it doesn't change - ever. Not to mention how fast it loads. How is that possible to have content zoom without the background image? I could understand if it was a repeated image but this is not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在该网站上,它看起来好像是由脚本完成的,正如 @rownage 观察到的那样,但我已经在现代浏览器中使用(CSS3)“cover”属性成功完成了它,即
background-size: cover;
background-size: cover; 根据我的笔记(欢迎评论!)这篇列出的文章< /a> 是我从哪里得到我的信息。在我的(仍在进行中!)照片网站上,目前看起来像这样。当放大我尝试过的浏览器时,背景保持相同的大小。如果 Internet Explorer 无法处理它,我也不会感到惊讶。
至于该网站上的图像加载速度快,诀窍只是选择一个良好压缩的可压缩图像。 我访问他们的网站时加载的背景是1024x680像素,但因为它主要是黑色和白色加上大面积的纯色,它被压缩到非常小的 74KB。
On that site it looks as though it's done by a script, as @rownage observes, but I've done it successfully in modern browsers using the (CSS3) "cover" property, i.e.
background-size: cover;
According to my notes (hurrah for comments!) this A List Apart article is where I got my information from.On my (very much still-in-progress!) photo site, it looks like this at the moment. The background stays the same size when zooming in the browsers I've tried. Though it wouldn't surprise me if Internet Explorer couldn't cope with it.
As to how fast the images on that site load, the trick is simply a good choice of compressible image, well-compressed. The background that loaded when I visited their site is 1024x680 pixels, but because it's mostly black and white with large areas of plain colour, it compresses down to a pretty tiny 74KB.
它使用 jQuery 和这个:
It uses jQuery and this: