Responsive Product Preview Card using HTM/CSS and a lot of Flexbox.
Design comparison
Solution retrospective
My process
I started creating the page already having in mind to use flexbox for practically everything, I know that some things could be solved with inline-block and adjusting margins and padding, but I need to train more the positioning of elements by flexbox.
I used Photoshop a lot to confirm dimensions and pixel count. I defined the size (width x height) of several elements, perhaps I wouldn't have needed to do it that way, but this gave me more confidence, with time I improve more in relation to this topic.
What I learned
This time I correctly used the media queries to create the mobile version, but I had a lot of difficulty changing the images according to the version.
It took me a long time to find a solution, a lot of research and mistakes to find an acceptable way to accomplish this.
The solution I found was to create two tags, one for each image and then use media queries to "hide" the image from the other layout with display: none
.
Using this mode, I believe the browser renders both photos, which is not good for performance and optimization. I would like to know a more efficient way to accomplish this.
Community feedback
- @VCaramesPosted almost 2 years ago
Hey there! 👋 Here are some suggestions to help improve your code:
- The image’s
alt tag
description needs to be improved upon ⚠️. Assume that you are describing the image to a someone over the phone.
More Info:📚
https://www.w3.org/WAI/tutorials/images/
- This component requires the use of two images 🎑 at different breakpoints ⚠️. The
picture
element will facilitate this.
Here is an example of how it works: EXAMPLE
Syntax:
<picture> <source media="(min-width: )" srcset=""> <img src="" alt=""> </picture>
More Info:📚
https://www.w3schools.com/html/html_images_picture.asp
- Do not uppercase ❌ "perfume" in HTML as it is not accessible friendly. Instead you will want to style it in CSS.
- The only heading ⚠️ in this component, is the name of the perfume; “Gabrielle Essence Eau De Parfum” . The rest of the text should be wrapped in a
paragraph
element.
- Currently, the old price (169.99) 🏷 is not being properly announced 😢 to screen readers. To fix this, you are going to wrap the the price in a
del
element and inside it you will add aspan
element with ansr-only class
that will state something like “The previous price was…” and use CSS to make it only visible to screen readers.
More Info:📚
If you have any questions or need further clarification, feel free to reach out to me.
Happy Coding! 🎆🎊🪅
Marked as helpful1@VCaramesPosted almost 2 years ago- Your content is not fully responsive. 😢 Here is a link to Google Developer’s site that will teach you how make it 100% responsive:
- For improved accessibility 📈 for your content, it is best practice to use
rem
for yourfont-size
and other property values. Whileem
is best formedia-queries
. Using these units gives users the ability to scale elements up and down, relative to a set value.
Marked as helpful1@VitorMagnagoPosted almost 2 years ago@vcarames Hi, thanks for the suggestions.
I still have a lot to improve on, especially in terms of responsiveness.
Thanks for the suggestion of sites, I have a lot to study.
0 - The image’s
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