無處不在的CSS sprites——是為數不多的幾個可以繞過“逐漸流行”階段,而直接讓自己成為CSS最佳實踐的Web設計技巧中的一個。盡管在A List Apart對它進行一個解釋以及贊同認可這種方式之前,它還沒有真正地流行。它最早是由Petr Stanícek.在2003年7月提出來作為一個CSS的解決方案。
Ah, the ubiquitous CSS sprites — one of the few web design techniques that was able to bypass “trend” status almost instantly, planting itself firmly into the category of best practice CSS. Although it didn’t really take off until well after A List Apart explained and endorsed it, it was discussed as a CSS solution as early as July, 2003 by Petr Stanícek.
當今許多web程序員對這項技巧(CSS sprites)有著很嫻熟的應用能力,介紹CSS sprites的教程和文章也是不計其數。幾乎在每一篇教程中,都要求設計師以及程序員應該實施CSS sprites以減少HTTP請求和節省帶寬。迄今為止,這項技術已經被許多網站所應用了,包括亞馬遜,正在使用著極大數量的sprites圖片。
Most web developers today have a fairly strong grasp of this technique, and there have been countless tutorials and articles written on it. In almost every one of those tutorials, the claim is made that designers and developers should be implementing CSS sprites in order to minimize HTTP requests and save valuable kilobytes. This technique has been taken so far that many sites, including Amazon, now use mega sprites.
可是 這項技術被廣泛熱議的帶來的好處真的值得么?設計師們是否可以在沒經過仔細考慮所有方面的因素的情況下轉而使用CSS sprites?在這篇文章中,我將來討論一下CSS sprites的一些贊同或者反對使用CSS sprites的意見,尤其集中在大量使用的sprites,以及為什么這樣子使用CSS sprites在許多情況下是等同于浪費時間。
Is this much-discussed benefit really worthwhile? Are designers jumping on the CSS sprite bandwagon without a careful consideration of all the factors? In this article, I’m going to discuss some of the pros and cons of using CSS sprites, focusing particularly on the use of “mega” sprites, and why such use of sprites could in many cases be a waste of time.
原文地址 譯者:solari