martedì, novembre 21, 2006

[Css] Simulare un rate (valutazione)

Fa tanto figo ultimamente riuscire a votare o valutare alcune pagine web, alcuni esempi di codice, alcuni script o delle immagini.
Qui di seguito elencherò un un pò di codice per simulare una valutazione (come su YouTube o Flickr).


XHTML:

[ul class='star-rating']
[li][a href='#' title='Rate this 1 star out of 5' class='one-star']1[/a][/li]
[li][a href='#' title='Rate this 2 stars out of 5' class='two-stars']2[/a][/li]
[li][a href='#' title='Rate this 3 stars out of 5' class='three-stars']3[/a][/li]
[li][a href='#' title='Rate this 4 stars out of 5' class='four-stars']4[/a][/li]
[li][a href='#' title='Rate this 5 stars out of 5' class='five-stars']5[/a][/li]
[/ul]


CSS:
.star-rating{
list-style:none;
margin: 0px;
padding:0px;
width: 100px;
height: 20px;
position: relative;
background: url(star_rating.gif) top left repeat-x;
}
.star-rating li{
padding:0px;
margin:0px;
/*\*/
float: left;
/* */
}
.star-rating li a{
display:block;
width:20px;
height: 20px;
text-decoration: none;
text-indent: -9000px;
z-index: 20;
position: absolute;
padding: 0px;
}
.star-rating li a:hover{
background: url(star_rating.gif) left bottom;
z-index: 1;
left: 0px;
}
.star-rating a.one-star{
left: 0px;
}
.star-rating a.one-star:hover{
width:20px;
}
.star-rating a.two-stars{
left:20px;
}
.star-rating a.two-stars:hover{
width: 40px;
}
.star-rating a.three-stars:hover{
width: 60px;
}
.star-rating a.three-stars{
left: 40px;
}
.star-rating a.four-stars{
left: 60px;
}
.star-rating a.four-stars:hover{
width: 80px;
}
.star-rating a.five-stars{
left: 80px;
}
.star-rating a.five-stars:hover{
width: 100px;
}

Link
komodomedia.com/blog/
Esempio in komomedia.com

View blog reactions

Nessun commento: