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

Card with an image with hover in HTML & CSS

Roy•195
@royschrauwen
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hello everyone! 👋

I got to upload another solution! Making the hover effect was a little challenging. And I still am not completely satisfied because I could not het the image of the eye as white as in the design. If anyone can tell me what I can do to improve it, that would be very nice.

Also, I could not get the line the same in Chrome as I got it in Firefox. Any pointers?

This was also my 6th day in the #100DaysOfCode Challenge!

If you have any advice, please let me know.

Have a nice day! 🙋‍♂️

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted over 3 years ago

    Hi

    There’s quite a bit to learn from this. most important of all is it’s essential for hover effects to be on interactive elements. Hovers indicate interactivity but you have no anchor tags at all on this. Essential to fix.

    Other pointers:

    • use min height 100vh never height. Your solution is cut off on mobile landscape screens because of that
    • use a css reset at the start of your style sheet and that will iron out visual inconsistencies across browsers. If you inspect in devtools look at the computed properties panel and you’ll see what browsers are applying to the hr. Probably background color, border and height.
    • a reset will usually set img tag to be display block and max width 100% which would be helpful to you on this. Then no need to size the image.
    • there’s no need to have a height on the card. The height can be auto calculated by the browser depending on the contents inside.
    • for the image hover, first it should be wrapped in an anchor tag as already stated. The alt text should be the link destination. I would add the hover effect using pseudo elements as there’s no need for them to be in the html. But if you want to have the eye image in html, it’s alt text would need to be left blank so it is ignored by assistive tech

    Hope this helps

    Marked as helpful
  • Jordan•70
    @Ciph-r
    Posted over 3 years ago

    Hello,

    Your card looks really good. I ran into the same issue with the view icon not being fully white. From what I've read the issue seems to be related to how opacity effects child elements. There might be a better fix but for mine I ended up setting the background to the cyan color with alpha instead of using opacity. So just "background: hsla(178, 100%, 50%, 0.5);" and then the icon shows up clearly.

    Hope that helps!

    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.

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

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