I am attempting to fix a display issue in Chrome with rating stars.
I have two divs with background images. The star is 18px wide so I have made the bounding div 90px (18x5). Within that another div is dynamically specified to show filled stars equivalent to the rating.
The example widths I've set out in the fiddle are based on a real example from my site. In Chrome browser only, with a width of 90px the stars do not line up. However if I reduce this to 89px for some reason the stars do line up.
I am not seeing the same issues in IE or Firefox.
I'd prefer to keep the width at 90px if there is a solution for this because otherwise the last star is slightly cut off in Firefox and IE, but I'm really scratching my head on what is causing the misalignment now.
Why are the stars misaligned in Chrome only?
https://jsfiddle.net/3hs0pnsq/
<style>
.rating {
background: url('http://www.solarreviews.com/images/star-18.png') repeat-x 0 0;
width: 90px;
height: 18px;
display: block;
}
.rating-star {
background: url('http://www.solarreviews.com/images/star-18.png') repeat-x 0 -18px;
height: 18px;
display: block;
}
</style>
<div class="rating">
<div class="rating-star" style="width: 72px;">
</div>
</div>
<br />
<div class="rating">
<div class="rating-star" style="width: 84px;">
</div>
</div>
<br />
<div class="rating" style="width: 89px;">
<div class="rating-star" style="width: 72px;">
</div>
</div>
Result: