Thursday, January 08, 2009 (Simple CSS Image Rollovers. Back to the Basics.)

Javascript rollovers?

Really?

Still?

Well, that’s just embarrassing.

Stop using those archaic Javascript rollovers and switch to a simple, time tested, CSS method.

For this example, let’s turn a commonly used “Read More” link into a colorfully interactive link of beauty. We’ll get right to it.

Your HTML:

  1. <a href="#" class="read_more">Read More</a>

Your CSS:

  1. a.read_more {
  2. display: block;
  3. width: 139px;
  4. height: 22px;
  5. padding: 4px 0 0 0;
  6. background: transparent url(read_more.png) no-repeat 0 0;
  7. text-align: center;
  8. color: #fff;
  9. text-decoration: none;
  10. }
  11. a.read_more:hover {
  12. background-position: 0 -25px;
  13. }

Your final product:

Shake some dust out of your yesteryear HTML/CSS and leave that javascript for rollovers behind, once and for all.

Once you’ve got the basics down, take it to the next step, with Simple Navigation with CSS Image Replacement.

Did you find this post helpful?

Posted in interweb

2 comments:

  1. Eric #

    *throws jellybeans at javascript*

  2. Bill Keller #

    Woot! There’s the attitude I love to see!

Leave a Comment:

HTML allowed: <a href=""> <strong> <em> <code>

Powered by WordPress using the Minimal, Really Theme. Inspired by Things