Design comparison
Solution retrospective
It actually went pretty well.
I think the media query could be more clear. Felt like I was going around adding px here and there. Probably a better way?
Open to hearing how to improve this code.
Thanks!
Community feedback
- @MelvinAguilarPosted about 1 year ago
Hello there ๐. Good job on completing the challenge !
I have some suggestions about your code that might interest you.
- Instead of using separate properties for
top
,right
,bottom
, andleft
withposition: absolute;
, you can use theinset
shorthand. For example, in your.main-image::before
selector:.main-image::before { . . . /* top: 0; */ /* right: 0; */ /* bottom: 0; */ /* left: 0; */ inset: 0; }
- Instead of having fixed values for properties like font-size, consider using the
clamp()
function. It allows for a scalable design by defining a minimum, preferred, and maximum value.
-
Instead of defining individual paddings and margins, consider using the shorthand. For example, the margin property in CSS has several shorthand properties that allow you to set the padding of multiple sides simultaneously:
- margin:
[top/bottom]
[left/right]
; - margin:
[top]
[right/left]
[bottom]
; - margin:
[top]
[right]
[bottom]
[left]
;
.main-content p { /* margin-left: 0; */ /* margin-right: 35px; */ /* margin-bottom: 60px; */ margin: 0 35px 60px 0; . . . }
The same concepts of the margin shorthand can also apply to
border-radius
andpadding
:-
border-radius:
[top-left]
[top-right]
[bottom-right]
[bottom-left]
;
- margin:
-
Instead of setting borders directly on the image, you can apply the border to the container element. Additionally, to crop any overflow of the image, you can use the
overflow: hidden
property on the container..main-container { . . . border-radius: 10px; overflow: hidden; /* <- Add this line */ } .main-image img { . . . /* border-top-right-radius: 10px; */ /* border-top-left-radius: 10px; */ }
I hope you find it useful! ๐ Above all, the solution you submitted is great!
Happy coding!
Marked as helpful3@jclegg31Posted about 1 year ago@MelvinAguilar thank you so much for the great tips and shortcuts! That's exactly the kind of stuff I'm looking for to try to improve! Appreciate it!
0 - Instead of using separate properties for
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