Forum Moderators: not2easy

Message Too Old, No Replies

CSS sprites and :after

         

jpiccolo

6:26 pm on Mar 25, 2008 (gmt 0)

10+ Year Member



Doctype:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>

The CSS looks like this:


a[href$=doc]:after {
content: " " url("/pa/images/icons/doc.gif");
}
Which puts a little word doc icon next to a link to a .doc file.
I have these for a couple different links, eg: pdf, wav, mp3

What I am trying to do is use CSS sprites because 30% of my page load time is for http get requests for the different images.

But the :after tag does not like a background image.
This is what I have so far (which puts the image there but not in the right spot):


a[href$=pdf] {
background-image:url(/pa/images/icons/test/14d171de5dd528e727e3f559e018a98c.png);
background-repeat:no-repeat;
background-position: -8px -232px;
width: 16px;
height: 16px;
position:relative;
top:0px;
left:0px
}

I am trying to do this with just CSS I would greatly not like to modify the source code (asp, html) to get this done.

Any help would be great, Thanks!

SuzyUK

7:04 pm on Mar 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi jpiccolo and Welcome to WebmasterWorld!

have you tried "display: block;", via a float if it's to be displayed 'inline', on the :after content - possibly won't need relative and top/left then? - initial display value of an element is inline, so block would be needed for image dimensions?

swa66

9:43 pm on Mar 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



:after is not supported at all by IE6.
You'll need JS there no matter how you attack it, unless you consider it a good thing to not have the feature for the ancient IE6, despite it's market share among the IE adepts.