Landing page responding to 4 different screen sizes
Design comparison
Solution retrospective
There's a couple of slightly different buttons in this challenge. What's the best approach for organizing these small differences in css?
My solution is to make a class button
for the white one, and a modifier button-accent
for the pink one. (i use bem with camelCase & single dash/hiphen) Both include different styling for various screen sizes. But the pink button is slightly different in some cases: a bit wider or has smaller text while keeping the same height. I reflected these changes in additional contextual classes: hero_button
& cta_button
.
Community feedback
- @GerbenDolPosted over 4 years ago
That's a great quest Alex and I like your solution!
I'd either do it that way, so add another modifier classes, or maybe I'd make it contextual in the sense of "When my
button-accent
is in myhero
section apply these extra styles.It kinda depends on the design which one will give the appropriate flexibility, but I think both work well. Your take on it I feel is more predictable and understandable, but making it depend on the wrapping div I feel makes it easier for me not to mess it up. No classes on the button I can forget to apply in different pages.
2
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