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

Stats Preview Card - HTML + CSS - Sek

sek-devops 110

@devwinner-sek

Desktop design screenshot for the Stats preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Difficulties on this challenge:

  1. How to manage height of the image on the mobile screen ? (i have used flexbox but i haven't reached the result i was expecting)

Solution i have used: increase height of my parent card (pass from 780px to 800px on mobile).

Is there a better solution ?

Community feedback

Lucas 👾 104,420

@correlucas

Posted

👾Hello @devwinner-sek, Congratulations on completing this challenge!

I saw your preview site and I liked a lot the work you’ve done here, it's almost complete, I’ve some suggestions you can consider applying to your code:

1.Use <main> instead of <div> to wrap the card container. This way you show that this is the main block of content and also replace the div with a semantic tag.

2.Use units as rem or em instead of px to improve your performance by resizing fonts between different screens and devices. These units are better to make your website more accessible. REM does not just apply to font size, but to all sizes as well.

3.Something you can do to improve the image that needs to change between mobile and desktop is to use <picture> instead of <img> wrapped in a div. You can manage both images inside the <picture> tag and use the html to code to set when the images should change setting the device max-width depending of the device (phone / computer) Here’s a guide about how to use picture: https://www.w3schools.com/tags/tag_picture.asp

✌️ I hope this helps you and happy coding!

Marked as helpful

1

sek-devops 110

@devwinner-sek

Posted

@correlucas Thanks very much for your suggestions. I have a great issue with responsive using only HTML + CSS. My goal is to master HTML CSS (i used bootstrap before).

Once again, thanks.

0
sek-devops 110

@devwinner-sek

Posted

@correlucas Please a question:

I saw the case i can use picture : <picture>

<source media="(min-width:650px)" srcset="img_pink_flowers.jpg"> <source media="(min-width:465px)" srcset="img_white_flower.jpg"> <img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;"> </picture>

It's very helpful.

But please i have a question:

By using img in HTML, can i give a background color to the image ?

I have used background image in this challenge because of the issue of background color for the image:

.card-right { border-radius: 8px 8px 8px 8px; background-image: url("../images/image-header-mobile.jpg"); background-color: #aa5cdb; background-blend-mode: multiply; background-repeat: no-repeat,repeat; }

0
Lucas 👾 104,420

@correlucas

Posted

@devwinner-sek is the same thing you can use img to apply the color to the image using the main selector for the image instead of using background-image its also better to do it using img than the css.

Marked as helpful

0
sek-devops 110

@devwinner-sek

Posted

@correlucas Ok thanks

0
Alan 160

@TheMax370

Posted

Hi Sek congrats on completing your challenge to answer your question, if there is a better solution? yes there is, instead of using absolute lengths you should look about relative lengths and learn how to use max-width, min-width, max-height and min-height this will help you in the future to make your containers more responsive and will save you a lot of resizing on the media queries I hope that answer your question.

Marked as helpful

0

sek-devops 110

@devwinner-sek

Posted

@TheMax370

Thanks for your suggestions

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