| Creating a Star Rater using CSS - CSS Tips and Tricks |
|
|
|
| Web Design | |||
| Written by motomoto | |||
| Friday, 03 July 2009 12:52 | |||
|
Quite awhile back, I wrote and article entitled Creating a Star Rater using CSS. In fact, if the CSS for this article is a little confusing, you may want to visit my previous articles to get yourself acquainted. I wrote it to my best ability and I shared what I could with the growing CSS-loving community. It was pretty flippin’ cool if you ask me, but it needed more. So, out of that need was born CSS Star Rating Part Deux, a vast improvement to the first, but by no means perfection. Out of the many comments I received about the most recent version, there were still some lacking areas. By now, people’s grasp as a whole has grown quite a bit I feel and I think that this time does not warrant a full-fledged tutorial (also, my lack of time doesn’t help either). However, there are some significant issues with my most current Star Rating tutorial and I have always wanted to take another go at it. In my thoughts, here is what the CSS Star Rating, part Deux is missing:
Well, thats the list! No wonder I wasn’t really happy with the thing. I remember when I first created it, it was my baby. Now, I hate the previous version. Whatever. Ok, enough rant from me. Lets get you guys up into the nerdy stuff. Ok, so for a refresher, here is the XHTML:No big shockers with the code. Basically new to the scene here is the fact that the inline rater is wrapped with a span and the small rater has an additional “small-star” class added. I’m sure you can imagine that you can call “small-star” any class you would like and adapt the CSS to your liking for the right size and image you would like. Next, in true throw-it-in-your-face tutorial style, here is the CSS:Basic Rater CSS.star-rating, The real difference between this CSS and my previous Star Rating tutorials has to do with the addition of :active and :focus pseudo states to hold the rating when clicked, percent-based widths, and the elimination of the use of floats to accomplish the CSS. It is important to mention also the use of overflow:hidden to keep the rater from spilling out over its set width and height as well as the use of a set pixel height line-height. I found that Internet Explorer really had issues with the rater CSS when resizing text, so if I set it to an exact pixel height, issues were resolved. Inline Rater CSS.inline-rating{ I found that if I wrapped the Star Rater unordered list with a span with a class of “inline-rating” and used the CSS rules above, I could achieve an inline rater. My apologies for the non-standard CSS attributes, but achieving an inline-block behavior in CSS is not an easy task. Most importantly to me is that it works and works in quite a few browsers. Smaller Rater CSS.small-star{ I’ve tried to make adapting the rater much easier for all of you. As you can see in the CSS above, you will not have to change a ton. Just add a class to your unordered list; In this case I used “small-star.” Update the width and height to the desired values. Make sure to change your image and line-heights as well. This makes creating other variations of the rater much more simple. If you need to make a 3 star, 4 star …N star rating system, you are gonna have to get your hands a little more dirty…sorry :(. I am much more happy with the performance and support of this version and I feel that it will help to resolve the shortcomings that the previous versions had.
|
|||
| Last Updated on Friday, 03 July 2009 12:54 |
| | Submit Article | |
Latest Community Articles
- Which Linux is right for me?
- Linux Shell Commands
- PHP Vs ASP.net
- What is Visual Basic.NET
- Using CURL On GoDaddy Shared Hosting
- [GMAIL] - [PHP] - Send email using PHP with Gmail
- Read XML Using SimpleXML in Php
- Ten more CSS tricks you may not know - css tips & tricks
- Ten CSS tricks you may not know
- CSS element hover effect - Tips and Tricks
- footerStickAlt: A more robust method of positioning a footer
- CSS Design: Going to Print - CSS Tips and Tricks
- Styling Your forms with CSS and Labels - CSS Tips and Tricks
- Creating a Star Rater using CSS - CSS Tips and Tricks
- CSS Tips and Tricks - rounded corners without images
- CSS Tips and Tricks - Rounded corners in CSS
- CSS Layout
- Voice over Internet Protocol (VoIP)
- Top 10 US Art Schools Compared
- Complete Outline of the Video Production Process
Top Members
| Member | Posts |
| ninz | 51 |
| zeff | 48 |
| codeshinobi | 14 |
| motomoto | 11 |
| jasmine | 6 |
| jbeter | 4 |
| mythone | 4 |
| Kirov_mark | 2 |
| simplychel | 1 |
|








