Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 3 years ago

html, css

Pratyusha Majumder•280
@YushaChan31
A solution to the Stats preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


This was hard for me. I tried. However, I have got a few questions. It would be really kind of you guys if you help me with it.

  1. The image in black and white and I have to use a color over it. so the image with black and white has shade of color on it. I saw the overlay method, linear gradient. . Finally I applied it but I think there is something wrong with my code. Mine is not coming similar to the original design.

  2. I have done the overlaying thing, but when I am increasing the resolution, that overlay div changes position , so it's not fixed over the image.

  3. Now coming back to the color thing, given is hsl format, linear gradient works better with rgba. So, I thought of converting hsl to rgb, but I was not satisfied, so kept hsl, and used opacity with it. But I still couldn't come close to the given picture in the design.

That's all , Thank you

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Danilo Blas•6,300
    @Sdann26
    Posted about 3 years ago

    Hi Pratyusha!

    This challenge is a bit annoying, ideally you should concentrate on doing the mobile design first and then the desktop design or vice versa. At the end you do what you are asked to do, the trick is to apply a parent div and inside the img image as its child. To the father apply a background-color that corresponds to him that I suppose that it is like pink and to the son give him mix-blend-mode: multiply and something of opacity and it will be equal to the design.

    The idea is that mix-blend-mode allows to merge an image with the color of the parent in this case the div that I mention to you.

    If you want to see how I applied it you can check the challenge when I did it so I also made it responsive.

    Don't worry, the experience comes little by little.

    Good Luck

    Marked as helpful
  • Lacey E•110
    @laceeder
    Posted about 3 years ago

    I recommend practicing mobile-first coding. I've found it's a lot easier to set up HTML and do the CSS for that. Your indents are also off after the opening body tag. I find it helpful to add a space between my content just so I can better keep track of my indents and stuff :)

    I also had a similar issue with my overlay, but my code is set up for mobile-first, so my recommendation may be a bit different. I would add another div class just for your images. So like this:

      
      <main>
        <div class="card">
          <div class="img-wrapper">
            <img class="img1"> />
            <img class="img2"> />
            <div class="overlay"></div>
          </div>
        </div>
    

    for me, I then was able to target the "img" and "overlay" divs and using DevTools in Chrome to get the height and width of the "img-wrapper" section, I was able to shrink the overlay and position it where I needed it. At least in mobile view, I'm working on desktop view now :)

    This is a tricky challenge and I hope this was at least semi-helpful! Keep it up! And remember: try to always practice mobile-first :)

    Marked as helpful
  • Ahmed Bayoumi•6,680
    @Bayoumi-dev
    Posted about 3 years ago

    Hey! To shade color on the image you need to create an element as the wrapper of the image and give it background color to blend it with the image to git color the image...

    HTML:

    <---! I moved the class `image1` from the image element to its wrapper__>
    
    <div class="image1">
          <img src="images/image-header-desktop.jpg" alt="image of people"> 
    </div>
    

    CSS:

    .image1{ 
        height: 400px;
        width: 500px;
        border-top-right-radius: 5px;
        border-bottom-right-radius: 5px;  
    
        
        background-color: hsl(277, 64%, 61%);   /* <---- Add */
        overflow:hidden;   /* <---- Add */
    }
    .image1 img {
        width: 100%;
        height: 100%;
        object-fit: cover;        /* to resize it to fit its wrapper */
        mix-blend-mode: multiply; /* blend with the content of the element's parent and the element's background. */
        opacity: 75%;
    }
    

    Hope this help!... Keep it up👍

    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub