Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Responsive Product Card using Vanilla CSS and HTML

Koi Hastilowβ€’ 90

@KoiHast

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


GitHub and I are about to go a round if I don't figure this stuff out soon. It didn't want to recognize my cart icon despite it being the EXACT SAME as it was on my desktop, and THAT was working.

ANYWAY, my biggest problem with this one was figuring out how to change images based on screen size. I think I figured it out, but if anyone wants to look over the code and see if I did it in a weird/incorrect way, I'd really appreciate it!

Community feedback

@MelvinAguilar

Posted

Hello there πŸ‘‹. Good job on completing the challenge !

I have some suggestions about your code that might interest you.

HTML 🏷️:

  • In my humble opinion, the tag <picture> is a very good choice when switching between images.
  • Avoid using uppercase text in your HTML because screen readers will read it letter by letter. You can use the text-transform property to transform the text to uppercase in CSS.

    The word "perfume" is written as separate letters, which does not convey the meaning that this text is a single cohesive unit of content. This can be confusing for users and for screen readers, as it can be difficult to understand the meaning of the text.

    Example:

    <p>Perfume</p>
    
    p {
        text-transform: uppercase;
        letter-spacing: 0.3em;
    }
    

Alt text πŸ“·:

  • The alt attribute should not contain the words "image", "photo", or "picture", because the image tag already conveys that information.
  • Not all images should have alt text. The cart-icon is a decorative image, it does not add any information to the page. You should use an empty alt attribute instead of a descriptive one. You can read more about this here πŸ“˜.

    If you want to learn more about the alt attribute, you can read this article. πŸ“˜.

CSS 🎨:.

  • Use min-height: 100vh instead of height. Setting the height to 100vh may result in the component being cut off on smaller screens, such as a mobile phone in landscape orientation.

    screenshot-imgur (landscape mode)πŸ“Έ

I hope you find it useful! πŸ˜„ Above all, the solution you submitted is great!

Happy coding!

Marked as helpful

0

Koi Hastilowβ€’ 90

@KoiHast

Posted

@MelvinAguilar Thank you so much for the feedback! I was also kinda confused when the accessibility report said I needed to add a descriptive alt attribute to the cart icon.

And that totally makes sense about not having "photo" in your alt tag. That was goofy of me. I should've caught that.

I didn't know that screen readers read capital letters as the actual letter names. I'll make sure to keep that in mind for the future!

0
Hassia Issahβ€’ 50,670

@Hassiai

Posted

To center the main on the page using flexbox, replace the height in the body with min-height: 100vh.

There is no need to give the main a height value, rather give .text-container a padding value for all the sides, this will replace the height of the main.

In the desktop design give .product-image and . text-container a width of 50% and the img a width of 100% and height of 100%.

In the media query, give .product-image and .text-container a width of 100%.

Use relative units like rem or em as unit for the padding, margin and width values, instead of using px which is an absolute unit. For more on CSS units Click here

Hope am helpful.

Well done for completing this challenge. HAPPY CODING

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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