Design comparison
Solution retrospective
** Hi there, I am Juan Martín and this is my solution for the Interactive Rating Component.
I had a rough time turning the buttons into perfect circles and I'm not sure if the result is the best possible. If anyone could answer this doubt for me it would be of great help.
Also, I'm not really sure if the names I assign to my classes is the best, If anyone could guide me on this I'd be most grateful.
Any other feedback is also welcome. Specially if it's constructive and specific.
Community feedback
- @ledesmxPosted 11 months ago
Hi Juan Martín Rivas 👋
Great job on your solution!
The rating component works pretty well.
To make perfect circles there is a better approach. Here's what I would do:
- First of all the padding will not help us in this case, so remove it.
- Then fix the
height
and thewidth
of the element to make a square. I suggest using theaspect-ratio
property together withheight
/width
. No problem if you useheight
andwidth
.
main .card .buttons-list .list-item > .rating-text { // height: 3rem; aspect-ratio: 1/1; }
- This along with the
border-radius: 50%;
will make a perfect circle. But the numbers will not be centered. Lastly, to center the content you can use eitherflex
orgrid
. I recommend usinggrid
along with theplace-content
property.
main .card .buttons-list .list-item > .rating-text { display: grid; place-content: center; }
In summary, I suggest adding this code:
main .card .buttons-list .list-item > .rating-text { height: 3rem; aspect-ratio: 1/1; display: grid; place-content: center; }
And removing this:
main .card .buttons-list .list-item > .rating-text { padding: .75em 1.25em; display: block; }
Regarding to your question about the classes' names I let you these links about BEM and SUIT CSS that I believe will be of great interest to you:
https://en.bem.info/methodology/
https://suitcss.github.io/
I hope this helps a little.
Well done for the rest.
Marked as helpful2@JuanMartinRivasPosted 10 months ago@AlbertoLed Thank you so much for your comment. I changed the styles on the rating buttons according to your recomendations. I'll definetely be using this method from now on every time I try to create circles in CSS. I've also been reading about BEM and SUIT CSS through the links you've sent me and I started applying this methodologies in the projects I'm currently working on. Once again thanks for your comment it was really helpful.
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord