Responsive preview card using CSS Grid & Flexbox
Design comparison
Solution retrospective
I'm most proud of using 'rem' in the majority of the project instead of 'px' to get a better responsive layout
What specific areas of your project would you like help with?I'm always open for new tips and suggentions and would love to chat with someone about it.
Community feedback
- @Islandstone89Posted 8 months ago
Well done, Victor.
A few suggestions:
HTML:
-
Don't use "image" in the alt text, as screen readers announce that by default.
-
Use the
<time>
element for the date:<p>Published <time datetime="2023-12-21">21 Dec 2023</time></p>
. -
The link should be inside the heading, not the other way around.
CSS:
-
Move
font-family
tobody
. -
Add around
1rem
ofpadding
on thebody
, so the card doesn't touch the edges on small screens. -
On the
body
, changeheight
tomin-height
- this way, the content will not get cut off if it grows beneath the viewport. -
max-width
on card should be in rem. -
Remove
max-height
on the top image.
Marked as helpful1@VFGarciaDevPosted 8 months ago@Islandstone89, Thank you for all your suggestions. I found everything very interesting and helpful, including the article about font-size. I'll try to implement more of your suggestions. I just have two questions about the CSS suggestions.
- Instead of rem, could I use '%' when assigning the 'max-width' on the card?
- What should I do to prevent the image of remaining on its original size if not using max-height/width?
1@Islandstone89Posted 8 months ago@VFGarciaDev Glad to help :)
-
No, use
rem
formax-width
. -
To prevent images from spilling out of their container, it is common to include the following in a CSS Reset, which should be added at the beginning of every stylesheet:
img { display: block; max-width: 100%; }
Marked as helpful1 -
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