Design comparison
Solution retrospective
I noticed while reducing the size of the browser. The card sticks to the right hand side of the browser, Can anyone kindly point out where i got it wrong
Community feedback
- @correlucasPosted about 2 years ago
👾Hello @SOULBRODA023, Congratulations on completing this challenge!
Your solution its almost done and I’ve some tips to help you to improve it:
1.Add the website favicon inserting the svg image inside the
<head>
.<link rel="icon" type="image/x-icon" href="./images/favicon-32x32.png">
3.Fix the alignment. The best way make this alignment is by using
FLEXBOX
. The first step, is to addmin-height: 100vh
to make the body height size becomes 100% of the viewport height, this way you make sure the container will be aligned vertically since thebody
will display ever 100% of the screen height. After that add two flex properties to make the alignmentdisplay: flex
/align-items: center;
/justify-content: center;
.2.Using
<picture>
you’ve more control over the elements and its better than using the product image as<img>
orbackground-image
. Look that for SEO and search engine reasons it isn't a better practice to import this product image with CSS since this will make it harder to the image. You can manage both images inside the<picture>
tag and use the html to code to set when the images should change setting the devicemax-width
depending of the device (phone / computer) Here’s a guide about how to usepicture
:https://www.w3schools.com/tags/tag_picture.asp
See the example below:
<picture> <source media="(max-width:650px)" srcset="./images/image-product-mobile.jpg"> <img src="./images/image-product-desktop.jpg" alt="Gabrielle Parfum" style="width:auto;"> </picture>
✌️ I hope this helps you and happy coding!
Marked as helpful0@SOULBRODA023Posted about 2 years ago@correlucas I really appreciate, I am new to coding thanks for correction. If I may ask for this particular challenge where more of the info of the product is on the right hand and we set the picture to change sizes based on device width. will the information on the right hand shrink alongside or there is a need for a media query
1 - @VCaramesPosted about 2 years ago
Hey @SOULBRODA023, great job on this project!
Some suggestions to improve you code:
- When using images that are different size for different breakpoints, its’ far more effective to use the <picture> element. By using this element not are able to use different size images, you can also save on bandwidth, meaning your content loads faster.
Syntax:
<picture> <source media="(min-width: )" srcset=""> <img src="" alt=""> </picture>
Source:
https://www.w3schools.com/html/html_images_picture.asp
https://web.dev/learn/design/picture-element/
- To make you content accessible to your users, it is a best to use rem/em instead of px for your CSS property values. For media queries, I definitely suggest using em for them. By using px your assuming that every users browser (mobile, tablet, laptop/desktop) is using a font size of 16px (this is the default size on browser). Em's will help with users whose default isn't 16px, which can sometimes cause the your content to overflow and negatively affect your layout.
Sources:
https://betterprogramming.pub/px-em-or-rem-examining-media-query-units-in-2021-e00cf37b91a9
Happy Coding!
Marked as helpful0@SOULBRODA023Posted about 2 years ago@vcarames I really appreciate, you have added more understanding to me
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