Skip to Content


Public news / October 2006 / Using Fewer Images

Using Fewer Images

Useful trick for optimizing your website. Use a single image by taking advantage of CSS image offsets.

permanent link 10 oct at 16:25 by Nate

There are 9 guest comments so far.

commentat 18:11 on 10 October 2006, Ed wrote:

This is a effective method that I've been using for the better part of the year now. So hopefully people will realize that they can approach things like their navigation and hover effects so much easier and better. It's nice to have clean code w/o javascript to do a hover effect.

commentat 20:25 on 10 October 2006, Kyle wrote:

Nice, definately something I will be able to take advantage of. I hadn't previously thought of that.

commentat 21:02 on 10 October 2006, Chris Williams wrote:

The only issue when using this technique is that you get a flicker when using IE with cacheing turned off.

The solution for this (especially when using UL LI & A hrefs for navigation) is to have the image also set as the background for the element below it (e.g. on the LI as well as the A).

commentat 21:17 on 10 October 2006, Phil Renaud wrote:

http://www.collylogic.com/scripts/rollover.html

By Simon Collison - I've used it for every site I've had to do since forever ago. Allows for alts, eliminates the flicker-in-IE problem as it sets it as a background image, and even allows for text-over-top without having to mess with the z-index.

pretty neat stuff for being, what, four years old now?

commentat 21:53 on 10 October 2006, Ed wrote:

It's funny as old of a technique this is.. There are still tons of people out there who create two images for their hover states.

If you want to take it one step further (once again not really) Add a 3rd level to the image to allow a "active" state.

But now that I think about it could a visited state be made as well?

commentat 22:52 on 10 October 2006, Chris Williams wrote:

Phil - Sorry, but Simon Collison's example doesn't fix the IE flickering problem when cacheing is turned off.

You need to add the background a third time underneath the A to fix this problem (unless there's another way?)

commentat 23:38 on 10 October 2006, will wrote:

long live the javascript powered rollovers!! :P

commentat 00:44 on 30 November 2007, yusuf wrote:

commentat 00:55 on 30 November 2007, chat wrote:

good, great

Add a comment:

(required, non-public)

  |  Chars left: 1000

Keep the comment relevant, constructive and be polite.
A valid email address or URL to your site must be provided, or the comment might get deleted. Content seemed inappropriate or offensive may be edited and/or deleted. Avoid explicit language and words such as "sucks" and "ripoff". For more in-depth discussions use our forum. Email addresses are never displayed. Line breaks and paragraphs are automatically converted - no need to use <p> or <br/>. Quotes & apostrophes are automatically converted to smart punctuation. Be careful when copying and pasting portions of entries or other comments. The following inline HTML elements may be used: <strong><em><pre><q><blockquote><code>. All other code will get removed before posting. Don't forget to close your tags.


Search the archive

Stylegala news archive

Public news archive

News contributors


Features

Stylegala BookStore
The Stylegala BookStore has a massive archive of great books for you as a professional..
Bullet madness
Bullet madness is a list of 200 bullets, arrows and icons uploaded by our users.
CSS Reference
An alphabetical list over the most common CSS1 and CSS2 syntax and properties.

Sponsors

Logo design for $149

Advertise here