Blog
Hot Off The Press
- Mosiac Man
- Sweet Talker
- Party Like It’s 1999
- Fishes Get Stitches
- A Real Dream
- Brooklyn Brewery Mash
- Pantone of the Year
- Thrift Shop Showdown
- Monthly Refresher v2, Yoga!
- Tyler Feder
Who Do You Love?
- Callum Beattie
- Charity Scantlebury
- Erin Heroux
- Jadyn Klassen
- Kerri Wilkinson
- Roberta Hansen
- Sherril Matthes
- Trisha Burch
Categories
- Advertising
- After Hours
- apps
- Art
- Awards
- books
- Branding
- Business
- campaign
- Company News
- Design
- fun
- gaming
- General Life
- Humour
- Illustration
- Inspiration
- Motion
- Movies
- Music
- National News
- Newest Work
- Newest Work
- Packaging
- Photography
- Printing
- Retail
- Technology
- Tips
- travel
- Typography
- Uncategorized
- Video
- Video of The Week
- Web
- World News
Archives
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
Web Tips 1: I’ll Have a Sprite.
To get in the habit of blogging more, I'm going to share some tips I use to develop better performing websites. This might be a little technical for the average person but anyone who has dabbled in HTML and CSS recently should be able to follow along just fine. Today I am going to cover CSS sprites—a simple way to consolidate template images to reduce requests to the server. They are used by the biggest websites and I first learned about them 2 years ago by studying Facebook's HTML code with Firebug. I tend to take frequently used images such as the logo, icons, ribbons and shapes, and I lay them out in Photoshop in one image using a grid. My grid is usually made up of 5px squares with 25 or 50px divisions. I have a CSS class, usually titled .main_sprite, that contains my sprite as a background image and other classes for each image on the sprite such as .logo. My logo class would contain my normal rules, such as the width and height of the element and also the position of the logo image on the sprite. I simultaneously write the CSS code as I create the sprite so that I can lock down the co-ordinates. Here is an example:
.main_sprite{background-image:url('sprite.png');background-repeat:no-repeat;}
.logo{width:200px;height:100px;display:block;background-position:-100px -50px;}
In the HTML, I would create my logo like this:
<a href="index.php" class="main_sprite logo"></a>
That's all there is to it! You now have one large image that you might be using in place of 20 different images, but the server isn't opening and processing 20 different connections. You also have the benefit of more effective browser image caching as the image was loaded via CSS which leads to all around gains.
TAGS: programming, web design
POSTED IN: Technology, Tips, Web
That’s an interesting way to use Sprites that I had not thought of. The only way I have used sprites is (for websites) for buttons with rollover so it doesn’t have that split second load making it look from 1990. Or at least all images that are the same size and category (eg buttons), but from what I am gathering from your post, is that you would use it for all your major images.