PDA

View Full Version : How to do AWS stars



Chris
02-12-2004, 11:04 AM
How to change numeric customer ratings to stars:



#startop{
z-index: 1;
background-image: url("/images/staryellow.gif");
background-repeat: repeat-x;
height: 12px;
}
#starbottom{
z-index: 0;
background-image: url("/images/stargrey.gif");
background-repeat: repeat-x;
width: 65px;
height: 12px;
}


The two star images are 13x12



$width = $Rating[$m] * 13;
echo '<div id = "starbottom"><div id = "startop" style = "width: '.$width.'px;"></div></div>';


Short and sweet.

Any questions?

Mike
02-12-2004, 11:07 AM
Nice :)

I'll add that when I get back from holiday next week.

incka
02-12-2004, 11:09 AM
I'll add it when I've uploaded my site...

GCT13
02-12-2004, 11:34 AM
I like that technique.

Chris
02-12-2004, 12:18 PM
Oh, by the way, you can nab the star images from my kitchen site (#14 in my signature).

flyingpylon
02-12-2004, 02:52 PM
Yeah, that's an interesting way to do it. It took me a little while to figure out what you were actually doing. My site just pulls the star images from Amazon and displays them, and they go to half-star increments. This method is more "accurate" but I'm not sure anyone would be able to see the difference unless they really looked. It might be easier to see the differences in a segmented bar or something. If nothing else, it's fewer lines of code.

Chris
02-12-2004, 04:27 PM
With larger stars its easier to see too.

pas
02-12-2004, 04:39 PM
I'd just repeat the IMG tag. If the CSS doesn't load, isn't support, is turned off, etc., it breaks.

Chris
02-12-2004, 04:54 PM
You can't turned CSS off. If it is included on the page itself it can't not load. If it doesn't load hopefully more is messed up than just some stars.

As for browsers that do not support it. At one point you just gotta write them off. You cannot continue to support browsers that are nearing a decade in age.

pas
02-12-2004, 04:58 PM
I know I've seen options in browsers (Mozilla, Firebird, Opera, maybe even IE) to enable/disable CSS and/or specify alternate/overriding stylesheets.