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.




