Rick Hurst Web Developer in Bristol, UK

Menu

useful CSS hack – replace an image with an.. er.. image

via hicksdesign:-


img {
width: 0;
padding-left: 20px;
background: url(mynewimage.gif) no-repeat;
}

I have a real-world example of where this would be useful in plone skinning – in some places inline images are still used for icons (here and there – they are generally being phased out). At the moment I usually set them to display:none and apply padding and background image to the containing element, but this may be a better solution.

archived comments

Just wanted to say thanks for this. 🙂 It is exactly what I need for over-riding some annoying hard-coded images in a blog I’m skinning.

Sarah Lewis 2007-05-04 16:45:04