Design comparison
SolutionDesign
Solution retrospective
After the project, I have two questions:
-
How to vertically center a span element?
-
Is it possible to set the height of a div same as the background image? (which mean can fully show the background image with correct scale)
Community feedback
- @larrasuPosted almost 2 years ago
Hello! Your solution looks excellent overall!
A few things you might want to add are the rounded corners of the card component and add
overflow: hidden
so the image molds into the rounded corners.To answer your questions:
- You can vertically center a
span
element by adding Flexbox to the parent element like this:
display: flex; items-align: center;
- Yes, it is possible to set the height of the
div
the same as the background image by addingbackground-size: cover
to yourdiv
. If you are using animg
element, you can also do it by addingobject-fit: cover
to yourimg
element.
I hope this helps! Happy coding ✨
0 - You can vertically center a
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