Design comparison
Solution retrospective
Feedback welcome.
Community feedback
- @0xabdulkhaliqPosted over 1 year ago
Hello there π. Congratulations on successfully completing the challenge! π
- I have other recommendations regarding your code that I believe will be of great interest to you.
CSS π¨:
- Looks like the component has not been centered properly. So let me explain, How you can easily center the component without using
margin
orpadding
.
- We don't need to use
margin
andpadding
to center the component both horizontally & vertically. Because usingmargin
orpadding
will not dynamical centers our component at all states
- To properly center the component in the page, you should use
Flexbox
orGrid
layout. You can read more about centering in CSS here π.
- For this demonstration we use css
Grid
to center the component.
body { min-height: 100vh; display: grid; place-items: center; }
- Now remove these styles, after removing you can able to see the changes
.card__container { margin: auto; margin-top: 50px; }
- Now your component has been properly centered
.
I hope you find this helpful π Above all, the solution you submitted is great !
Happy coding!
0 - @dimar-hanungPosted over 1 year ago
Hi.. π, Congratulations on completing the challenge πΒ .
I have some interest and feedback with your code
That i like:
- I appreciate the similarity of your results with the design, a bit different in position and scale but still good
- HTML is pretty good, not too nested and combination of semantic HTMLπ
- Responsive until galaxy fold screen size (280 x 653)px π
- CSS Naming is also good, represent what is it for, likeΒ
<div class="price">
Β for price section
My Feedback:
-
Javascript is not needed in this solution, you can use only css on view hover
-
1 - Remove
main.js
-
2 - change and add this to
style.css
.card_container .banner_image_container .hover_state { /* display: none; */ position: absolute; width: 250px; height: 250px; margin-left: 25px; margin-top: -16rem; border-radius: 10px; background-color: var(--cyan-color); /* set opacity to 0 instead display none */ opacity: 0; /* add transiton to make it more smooth */ transition: opacity 0.3s ease-in-out; } .card_container .banner_image_container .hover_state:hover { opacity: 0.3; cursor: pointer; }
-
-
Using grid you can make it center, change
body
andcard-container
instyle.css
to :body { background: var(--main-background); color: white; min-height: 100vh; display: grid; place-items: center; } /* card container */ .card_container { background: var(--card-dark-blue); width: 300px; height: 500px; border-radius: 10px; margin: auto; box-shadow: 0px 2px 10px 0px var(--card-dark-blue); /* remove margin */ /* margin-top: 50px; */ }
Overall, well done - your innovative approach using js is actually good! π, hope it's helpful π
0 - @pperdanaPosted over 1 year ago
Hi, Well done on completing the challenge! π
- I have more suggestions regarding your code that I believe will be highly beneficial for you.
π Center an element both horizontally and vertically
Using flexbox:
Set the display property of the parent element to "flex" and use the "justify-content" and "align-items" properties to center the child element both horizontally and vertically. For example:
.parent { display: flex; justify-content: center; align-items: center; } .child { /* other styles for the child element */ }
I hope this information was beneficial for you! π
Happy codingπ€
0
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