| 关于 css sprite | |
|  | 发起人:piaoling 回复数:0 浏览数:7531 最后更新:2009/6/16 16:29:11 by piaoling | 
| 选择查看 | 搜索更多相关主题 帖子排序: | 
| piaoling 发表于 2009/6/16 16:29:12 | 
| 关于 css sprite   CSS Sprites是一种网页图片应用处理方式。它允许你将一个页面涉及到的所有零星图片都包含到一张大图中去,这样一来,当访问该页面时,载入的图片就不会像以前那样一幅一幅地慢慢显示出来了。对于当前网络流行的速度而言,不高于200KB的单张图片的所需载入时间基本是差不多的,所以无需 顾忌这个问题。 按照yahoo的rules for high performance web sites的原则,应当较少Client与Server端间 的HTTP Request次数。通过CSS Sprites方法将多张图片组装成单独的一张图片,可以有效减少HTTP请求 的次数。 当整幅图片载入完成后,你就可以使用CSS方法通过设置背景位置的方式完成所需图片的准确调用。 加速的关键,不是降低重量,而是减少个数。传统切图讲究精细,图片规格越小越好,重量越小越好,其实规格大小无所谓,计算机统一都按byte计算。客户端每显示一张图片都会向服务器发送请求,所以,图片越多请求次数越多,造成延迟的可能性也就越大。 
 1. 图片限制(Image Slicing)[1]   典型如文本编辑器,小图标特别多,打开时一张张跑出来,给用户的感觉很不好。如果能用一张图解决,则不会有这个问题,比如百度空间、163博客、Gmail都是这么做的。   Image Slicing’s Kiss of Death   http://www.alistapart.com/articles/sprites   2. 单图转滚(Single-image Rollovers)[1]   触发切换图片的需求,传统方案得重新请求新图片,因为网络问题经常造成停留或等待。如果能把多种状态合并成一张图,就能完美解决,然后再使用背景图技术模拟动态效果。   ColorScheme Ratings   http://demo.rexsong.com/200608/colorscheme_ratings/   3. 延长背景(Extend Background Image)[1]   如果图片的某边可以背景平铺无限延长,则不需要每个角、每条边单独搞出来,图片能少一个就少一个。其实,这个理论还可以扩展到四角容器里,好处是能大大简化HTML Structure。   Extend Background Image   http://demo.rexsong.com/200705/extend_background_image/   综合案例   Google Korea(1和2技巧)   http://demo.rexsong.com/200705/google_korea/   CSS Menus(2和3技巧) http://demo.rexsong.com/200705/css_background_menus/ 
 相关资源:  What Are CSS Sprites?   http://www.peachpit.com/articles/printerfriendly.aspx?p=447210&rl=1   CSS Sprites: Image Slicing’s Kiss of Death   http://www.alistapart.com/articles/sprites/   CSS Sprites Generator   http://www.csssprites.com/   http://spritegen.website-performance.org/   Fast Rollovers Without Preload   http://wellstyled.com/css-nopreload-rollovers.html   JavaScript Sprite Animation Using jQuery   http://www.sitepoint.com/blogs/2007/07/20/javascript-sprite-animation-using-jquery/   http://www.sitepoint.com/blogs/2007/07/05/css-using-percentages-in-background-image/   How to create CSS sprites   http://fatagnus.com/how-to-create-css-sprites/   Creating Rollover Effects with CSS Sprites   http://www.devarticles.com/c/a/Web-Style-Sheets/Creating-Rollover-Effects-with-CSS-Sprites/   Building a Dynamic Banner with CSS Sprites   http://www.devarticles.com/c/a/Web-Style-Sheets/Building-a-Dynamic-Banner-with-CSS-Sprites/   CSS Sprites and IE/Win Flicker Issue   http://www.brajeshwar.com/2006/css-sprites-and-iewin-flicker-issue/   css用法测试工具:CSS tests and experiments http://www.brunildo.org/test/index.html | 
| 返回页首↑ |