Image replacement

Pre 2006

Image Replacement

If you have 'images on' and 'css on' then the above text is an image.

Image Replacement

If you have 'images on' and 'css on' then the above text is an image link.

copyright © stu nicholls - CSS play

Information

There are so many ways of doing this that I have lost count, a few of them are listed here image-replacement

But this is the way I would normally do it should anyone be interested.

This way requires an empty <em> tag to hold a background image which is then used to hide the text and satisfies the usual 'images off / css on' and 'css off' conditions. I am sure that it must have a *IR acronym already allocated and I do not claim it as my own.

It is fairly straightforward and easy to implement BUT does have a small problem in that you cannot use transparent or opaque images as the text will show through. However for most cases this is a suitable method.

If you don't mind the text appearing around the image when resized large enough then you can leave out the height/width/overflow styling of the h2.ir. You can also add title="Image Replacement" to the em tag if you wish so that it will appear on hover. Finally, you could always make the image area large enough to cover any text resizing (as in my example).

1st March 2006

A change of background image on hover added.

Cascading Style Sheet

h2.ir {
  position:relative; 
  width:350px; 
  height:60px; 
  padding:0;
  overflow:hidden;
  }
h2.ir em {
  display:block; 
  width:350px; 
  height:40px; 
  background:url(../images/ir.gif); 
  position:absolute;
  top:0;
  left:0;
  }

xhtml

<h2 class="ir"><em></em>Image Replacement</h2>

Copyright

You may use this method on your personal 'non-profit' web site without seeking my permission. A link back to CSSplay is always appreciated.

Commercial usage is also permitted without seeking approval, but I would ask that a donation is considered to support my work on CSSPlay.

If you are having problems integrating any of my demonstrations into your website then I now offer a service to fault find and correct any errors that you may have introduced. Please email me for more information.



Please Support CSS play

Please note that if your donation is for a demo/menu then you will need to email me with the url of the demo/menu after making the donation

For more CSS demonstrations I recommend that you visit the Dynamic Drive CSS Library.


Free, practical CSS menus, layouts, and examples

Soft Geometry Creative Industries

Soft Geometry Creative Industries
is a music-based design company located in Bristol UK.
I create artwork for albums, singles, posters and t-shirts.
My work is influenced by punk and post-punk poster and flyer design,
lo-fi photocopy aesthetics,
Francis Bacon and Mark Rothko.

I can provide a start to finish service with my own art and photography, put together work from images provided by yourself, and collaborate on an idea.
softgeometrycreative{at}gmail.com

Follow CSS play


Facebook   Twitter   Facebook Fan Page