Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 7 months ago

Responsive nft-preview-card using React.JS

react, pure-css
P
Nishanth Venkatesan•1,030
@nishanth1596
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

This is the first challenge I’ve completed using React.js. I’m proud to have finished it in a short amount of time, as I’m becoming more comfortable with coding. I’m excited to continue improving every day!

What specific areas of your project would you like help with?

I'm having trouble adding a cyan background color on hover for an image. Despite my efforts, I haven't been able to achieve the desired effect. I would greatly appreciate any help or suggestions on how to fix this small issue.

Thank you in advance!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Teodor Jenkler•4,040
    @TedJenkler
    Posted 7 months ago

    Hi @nishanth1596,

    I have some additional feedback to help improve your project:

    Content for ::before and ::after: I noticed that the first feedback missed mentioning content: "". This is essential for ::before and ::after pseudo-elements. Using this overlay method, as @MarziaJalili mentioned, is recommended because it allows you to add hover effects and animations to the other layer while achieving the desired overlay effect.

    <main> Element Usage: It seems you're using the <main> element incorrectly. In your index.html, you can replace the #root div with a <main> element, provided you're not including a <footer> or <header>. This aligns with best practices for semantic HTML.

    Reducing Divs and Containers: You're using too many <div> and container elements. Aim to minimize these where possible. I recommend learning more about Flexbox to reduce the complexity associated with extra padding and margins in your card layout. Simplifying your structure will result in cleaner, more maintainable code, which is especially helpful in larger projects. (In React, you can use <></> for cleaner code when working with components.)

    List Element Usage: Be cautious with how you use lists (<ol> or <ul>). These should only be used for ordered or unordered lists. Misusing them can confuse the structure and semantics of your content.

    SEO Practice: I recommend practicing the use of SEO titles and descriptions in all your projects. Try adding these to your index.html, then share your project on Discord or social media before and after implementing these changes to observe the differences in visibility and engagement.

    Keep up the good work!

    Marked as helpful
  • Marzia Jalili•9,650
    @MarziaJalili
    Posted 7 months ago

    Well done man,

    Here's the answer to your question:

    As far as I know we can't directly change the background of an image.

    Therefore, we have to use the ::before or ::after pseudo element.

    But the img element doesn't support them. So we set them on the parent element of the img.

    • Take the line below as an example for the HTML:
    <div className="image-parent">
      <img className="image" src="path of the image" alt="image"/>
    </div>
    
    • Then apply the lines below in CSS:
    .image-parent {
      position: relative; 
    }
    
    .image-parent::before {
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: cyan; /* or the code of the color */
      opacity: .5; /* if you want the image to be seen */
    }
    

    By implementing these lines your will definitely achieve the desired effect😎.

    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

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