Design comparison
Solution retrospective
- I found it difficult with creating a color overlay over the image and also setting the card component at the centre of the page.
-none
-Is there any best practice for setting the main components at the center of the body. also would like to ask for best practices to set a color overlay on an image using divs.
Kindly check my code and leave me a feedback. I sincerely value you feedback.
Community feedback
- @javascriptor1Posted over 1 year ago
Hi Nikkaburger ,
Nice work. Here are some notes which I hope would answer your questions :
1- To center a card component or a div in the page , There are many methods you can follow to achieve that. Here are few of them :
1- Using flexbox. Apply these properties on the body tag :
` body { display: flex; align-items: center; justify-content: center; min-height: 100vh; // if you overlook this property , it won't work }
`
2- using Grid.
body { display: grid; place-content: center; min-height: 100vh; }
3- Using absolute positioning. Create a div and give it following properties :
` div { position: absolute; inset: 0; margin: auto; width: 100px; height: 100px; }
`
2- to create overlay over an image , do the following : Create a div and add an image as child inside the div. then style as following ; ` .img-div { width: 100%; background-color: var(--soft-violet); border-top-left-radius: 8px; border-top-right-radius: 8px; }
img { width: 100%; border-top-left-radius: 8px; border-top-right-radius: 8px; mix-blend-mode: multiply; // change this property as per your need display: block;
`
Hope this would help
Keep coding 🚀
Marked as helpful0
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