开发者

Images being requested multiple times from CSS

开发者 https://www.devze.com 2023-04-07 19:28 出处:网络
Any idea what would make a stylesheet(s) load images multiple times?The images are the same URL, nothing fancy going on.

Any idea what would make a stylesheet(s) load images multiple times? The images are the same URL, nothing fancy going on.


EDIT: Only happens in safari (5.0.3) in both iPhone "mode" and default "mode" - i cannot reproduce the problem in FF or IE.开发者_高级运维

Apache_access_log says that the image is indeed being accessed multiple times.

When adding styles that call the image back in one-by-one, they don't seem to follow any pattern as to when they will start to double up.

I also tried making the image significantly smaller to see if it was a cache issue. Didn't change anything.


Not sure what the deal is with Safari, but apparently:

If the CSS rules that reference the same sprite-sheet are not grouped together, it will request the image more than once. (Although not the full number of times the call appears).

#divOne, #divTwo, #divThree {
    background-image: url('IMGURLHERE');
}

This would request the image one time.

#divOne {
    background-image: url('IMGURLHERE');
}

#divTwo {
    background-image: url('IMGURLHERE');
}

This would request the image twice.

No idea as to why this happens.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号