Design comparison
SolutionDesign
Solution retrospective
Any tips on how to try and cut down on how much I have to repeat my css? I tried not doing it too much but I still feel there's quite a bit of repeating stuff in there. Thanks
Community feedback
- @markuslewinPosted over 1 year ago
If multiple classes use the same properties, you could move those properties into a new class and apply both classes to the element, like you did with
.border-radius
!Some examples:
.stack { display: flex; flex-direction: column; } /* properties can be removed from `body`, `.score`, `.result`, `.summary`, `.summary-list` */
.icon::before { content: ""; position: absolute; top: 30%; left: 5%; width: var(--icon-width); height: var(--icon-height); z-index: 9; } .reaction::before { background-image: url(./assets/images/icon-reaction.svg); } /* using variables: */ .icon::before { content: ""; position: absolute; top: 30%; left: 5%; width: var(--icon-width); height: var(--icon-height); z-index: 9; background-image: var(--icon-image); } .reaction::before { --icon-image: url(./assets/images/icon-reaction.svg); }
Marked as helpful1@HonkyTonkTPPosted over 1 year ago@markuslewin Oh, thanks for the example, I will use that in the future. Still new to using variables, I keep forgetting that you can actually change them after they've been set once.
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