Bjørn Wikkeling
Sep 4, 2018 · 1 min read

That was a very interesting read! It got me thinking whether it would be possible to make the star ratings 100% pure CSS. Have a look at my example on codepen.

I did add a tiny bit of JS for possible posting to a server or local storage, but that can be condensed into 3 lines :)

document.querySelector('.stars').addEventListener('click', e => {
// figure out which star was clicked
const rating = Array.from(e.currentTarget.querySelectorAll('input')).indexOf(e.target) + 1;
});
// see codepen for full code example:
// https://codepen.io/magikMaker/pen/RYgbwy/

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store