开发者

Faster to use individual resource file, or individual files?

开发者 https://www.devze.com 2023-04-06 09:09 出处:网络
Is it faster to create an individual resource file like this, containing multiple icons/images: http://static.ak.fbcdn.net/rsrc.php/v1/y7/r/ql9vukDCc4R.png or create multiple files with an individual

Is it faster to create an individual resource file like this, containing multiple icons/images: http://static.ak.fbcdn.net/rsrc.php/v1/y7/r/ql9vukDCc4R.png or create multiple files with an individual file in each. It seems like it would be faster with a single file, because you have to only download a file once, but it would take time to adjust the background-position CSS attribute for each class in your CSS file. I am a little lost here, because I see different websites doing different techniques, and I am wonde开发者_开发问答ring which would be best.


This is called "CSS sprites". As long as the single file is not so huge that it slows down the loading of the site, then it's a good technique to use.

If these are the main UI items for the site, it's worth the time to code them in CSS positons. It doesn't really take that much longer to code and there are few files to deal with.

Example: http://skyje.com/2010/02/css-sprites/

Example: http://coding.smashingmagazine.com/2009/04/27/the-mystery-of-css-sprites-techniques-tools-and-tutorials/

0

精彩评论

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