覆盖CSS背景图像样式 - 两个图像都加载? [英] Overriding CSS background image styles - both images are loaded?

查看:90
本文介绍了覆盖CSS背景图像样式 - 两个图像都加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有2个CSS样式将背景图像分配给一个元素,并且一个样式覆盖另一个。这两个图像是由浏览器下载还是只是压倒性的?



我之所以问,我最近参加了一个关于移动设备条件样式表的研讨会。如果我用较小的覆盖我的正常BG图像以节省带宽,无论如何将加载较大的图像?这似乎是这个家伙说的,但对我来说,这似乎很奇怪。

解决方案

在某些情况下,答案似乎是:

http://www.cloudfour.com/css- media-query-for-mobile-is-fools-gold /

http://www.cloudfour.com/examples/mediaqueries/image-test/#t4


If I have 2 CSS styles that assign background images to an element, and one style overrides the other. Will both images be downloaded by the browser or just the overriding one?

I reason I'm asking is I recently attended a workshop on conditional stylesheets for mobile devices. If I override my normal bg images with smaller ones to save bandwidth, will the larger images be loaded anyway? This seemed to be what the guy was saying but it seems strange to me it would work this way.

解决方案

It seems in some cases the answer is yes:

http://www.cloudfour.com/css-media-query-for-mobile-is-fools-gold/

http://www.cloudfour.com/examples/mediaqueries/image-test/#t4

这篇关于覆盖CSS背景图像样式 - 两个图像都加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆