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 stats preview card using flexbox

P
Koyaβ€’ 310

@koyaboy

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


So I attempted this project right after learning about responsive web design. I followed the advice and best practice of styling mobile first. It was pretty easy and I got through it fast. Then came adjusting the styles for the desktop fit. This was going well until I came about trying to fit the image. As a result of that, I have a few questions below:

  • First of all, For the mobile version, the card container height was responsive but for the desktop view , I gave it a fixed height so that I can also give the image the exact same fixed height. Is that ok ? Or is there another route I could have taken that doesn't involve me giving the card a fixed height and the image will still match with the height responsiveness of the card ? (I already gave the image a width of 50%). This part took me quite some time because I was thinking there was a way to make the height of the image grow with the card when the screen size is reducing so if you have an answer to this question it would be much appreciated

  • Second of all , the breakpoint for my media query is at 900px because that is when my desktop layout was practically breaking. I read somewhere that media query breakpoints are layout specific and not screen specific. I just want to confirm whether that breakpoint is actually ok ?

@media (min-width: 900px) {

    body {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .card {
        width: 80%;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        margin: 0;

        height: 480px;
    }

    .main {
        width: 38%;
        margin-left: 2.5em;
        text-align: left;
    }

    .main-heading {
        margin-top: 1.6em;
        margin-bottom: 1.2em;
    }

    .main-paragraph {
        line-height: 30px;
        margin-bottom: 5.5em;

        font-size: 1rem;
    }

    .stats {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
    }

    .stats-paragraph {
        font-size: 0.7rem;
    }

    img {

        min-width: 50%;
        border-radius: 0 10px 10px 0;
        width: 40%;
        height: 480px;
    }

  • I would like to know if there's another approach to adding image overlay ? Is the approach I used ok ?
img {
      filter: opacity(0.3) drop-shadow(0 0 var(--image-background-color));
}

  • Would using grid here have been much easier ?

  • If there's any suggestion you have for the code or structure I'm more than happy to hear feedback. If you know of a better approach, please do kindly share, it'll help me out a lot

THANK YOU

Community feedback

P
visualdennisβ€’ 8,375

@visualdenniss

Posted

Hey there,

first of all, nice work. Let me answer your questions as much as i can:

Regarding color filter for the image:

  • The image should be wrapped in a container div.
  • Then Change background color of the image container div to this: background: hsl(277, 64%, 61%);
  • Then add {mix-blend-mode: multiply; opacity: 0.75; } only to the img.

Regarding fixed height:

  • You should avoid giving fixed heights as much as possible. This will cause tons of issues from overflowing texts or contents if the data is dynamically rendered, accessibility issues if user changes base font size etc etc. Give min-height instead if you have to.

Regarding breakpoints

  • Yes, adjust the breakpoints to your needs, 375px etc are actually not the breakpoints. Your app should look good between as low as 280px or 320px at least and as high as 2500px. The given designs show how the app should exactly look like on 375px and 1440px screens, but it is best to have a good and responsive layout for anything between the range of 320px and 2500px. Basically you shouldn't only be coding for 375px and 1440px. Hope this clarifies. So it is great that you have used different breakpoints according to your needs

  • There are more issues such as giving max-width: 1440px; to body instead of main, and the HTML Structure seems not to be optimal. Feel free to check out my solution to get some more ideas for the layout structure in HTML (not in terms of semantic)

Hope you find this feedback helpful!

Marked as helpful

0

P
Koyaβ€’ 310

@koyaboy

Posted

@visualdenniss Thanks dennis, you've been a real help. I'll add these changes and see if I can get closer to the design

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