Design comparison
Solution retrospective
Any advice on improvement is much appreciated. :) Some questions:
- not sure if it would have been more efficient setting the font-size based on
vw
? Could have been more responsive on scaling? (however the growth seemed rather unpredictable and gave up) - wonder if i couldn't have selected the buttons based on nth-of-type/nth-child instead of adding an ID for them, should have been possible?
- based on the template for mobile I approximated the font ~9px that seems rather small?
- when testing my solution on mobile/iOS the buttons disappear - my guess is something with the
:active
& touchscreen (since it looks ok on different resolutions on desktop).
Community feedback
- @vanzasetiaPosted over 3 years ago
👋Hi Ash! My name is Vanza!
I would like to answer your questions:
- In my opinion, the best unit for
font-size
isrem
unit, because it allow the user to control thefont-size
. If you want to usevw
, you can do that if you useclamp()
function. I would look something like this:
font-size: clamp(1rem, 0.8750rem + 5vw, 3.5rem);
- My recommendation on selecting
button
is by using class. Like for instance, if you have a bunch of buttons:
<header> <button></button> </header> <section> <button></button> </section> <footer> <button></button> </footer>
Instead of using
id
, you can usebtn
generic class and then for the specific styling you can add modifier classes.<header> <button class="btn btn--header"></button> </header> <section> <button class="btn btn--section"></button> </section> <footer> <button class="btn btn--footer"></button> </footer>
So, in your css you don't have to use
id
ornth-child
to make sure that the specificity is at a low level:/* General Button Styling */ .btn { display: inline-block; border: 1px solid orangered; padding: 1rem; } /* Specific button styling */ .btn--header { background-color: steelblue; } .btn--section { background-color: red; } .btn--footer { background-color: orangered; }
This approach is using BEM methodology.
- Yeah, it seems small on the mobile, try to increase the
font-size
a bit. - No, it doesn't disappear on my mobile phone.
That's it! Hopefully this answer all your questions!
Marked as helpful4@nyxravenPosted over 3 years ago@vanzasetia Hi Vanza, thank you so much for your answers! Much appreciated, will try :)
0 - In my opinion, the best unit for
- @brasspetalsPosted over 3 years ago
Hi, Ash! Congrats on completing another challenge!
Vanza has already given you some excellent advice, so I don't have much to add. 😄
For Safari and iOS mobile, I believe the issue will be fixed if you set the
background-color
on the.card-button
. 👍Marked as helpful0
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