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

HMTL & CSS

Luis Fuentes•50
@EleganteOso
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


open to suggestions to implement the icon-view.svg

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Vanza Setia•27,715
    @vanzasetia
    Posted almost 3 years ago

    Hi, Luis Fuentes! 👋

    Regarding the icon-view.svg, I would recommend showing it with pure CSS, pseudo-element and background properties. You can actually create the entire overlay by only using CSS (not only the eye icon).

    So, the way it works is to get the HTML right first so that it's accessible by screenreader users.

    • First, we need to make the HTML right so wrap the image with an anchor tag (or button depending on what you would think will happen after the users click it). Then, add aria-label to give some text content.
    • Second, make the img as a block element and then set max-width: 100%. Make sure you leave the alt="" empty.

    Now, for the styling.

    • First, create a pseudo-element from the anchor tag (it could be ::after or ::before).
    • Second, make the pseudo-element fill the entire image by using absolute positioning.
    • Lastly, you can target the pseudo-element when the anchor tag is hovered, then show the background image and the background color. (a:hover::after)
    • Note: adjust the opacity of the background color by changing the alpha value. Not, by using the opacity property.

    I notice that the attribution is disappearing for mobile users. I would recommend keeping it because mobile users would not have the same amount of information as desktop users. Also, not to mention that there are a lot of people are online through their mobile phones.

    Hope this helps. 🙂

    Marked as helpful
  • Esteban•150
    @ehmenzala
    Posted almost 3 years ago

    ¡Hola @EleganteOso!

    • Veo que, al realizar :hover sobre el <div></div> que contiene a tu imagen, le asignas a la imagen una opacidad (opacity) de 0.5.
    • Pienso que está bien implementada tu solución por esa parte.

    Para implementar el ícono te sugiero lo siguiente...

    Al <div></div> que contiene la imagen, puedes asignarle también la propiedad background-image: url();. Dentro de url() debes colocar, con comillas dobles o simples, la ruta hacia la imagen del ícono del ojo. No te olvides de asignar la propiedad background-repeat: no-repeat;. Y asegúrate de posicionar bien el ícono con la propiedad background-position.

    Tips extras...

    En el título de tu tarjeta, al poner el cursor a la derecha de este —sin tocar ninguno de sus caracteres—, se dispara el evento :hover sobre el título (Se aplica el color celeste al título). Para evitar esto te sugiero que en <h1 class="title">Equilibrium #3429</h1> asignes la propiedad width: max-content; para que el :hover solo se aplique cuando apuntas con el cursor sobre las letras del título, mas no a los lados.

    Te dejo un enlace hacia la documentación de la propiedad max-content por si quieres echarle un vistazo...

    ¡Suerte! 👋

    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 1st-party linked stylesheets, and styles within <style> tags.

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.

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