{"id":22031536,"url":"https://github.com/paatre/nft-preview-card-component","last_synced_at":"2026-05-08T13:48:22.729Z","repository":{"id":199016287,"uuid":"526753147","full_name":"paatre/nft-preview-card-component","owner":"paatre","description":null,"archived":false,"fork":false,"pushed_at":"2022-08-20T21:29:03.000Z","size":370,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T18:13:47.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"SCSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paatre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-08-19T21:13:52.000Z","updated_at":"2022-08-20T21:29:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"3736d745-ad8f-4e37-9fc8-3f14dd103e53","html_url":"https://github.com/paatre/nft-preview-card-component","commit_stats":null,"previous_names":["paatre/nft-preview-card-component"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paatre%2Fnft-preview-card-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paatre%2Fnft-preview-card-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paatre%2Fnft-preview-card-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paatre%2Fnft-preview-card-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paatre","download_url":"https://codeload.github.com/paatre/nft-preview-card-component/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245094002,"owners_count":20559831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T08:19:07.492Z","updated_at":"2026-05-08T13:48:17.696Z","avatar_url":"https://github.com/paatre.png","language":"SCSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Frontend Mentor - NFT preview card component solution\n\nThis is a solution to the [NFT preview card component challenge on Frontend Mentor](https://www.frontendmentor.io/challenges/nft-preview-card-component-SbdUL_w0U). Frontend Mentor challenges help you improve your coding skills by building realistic projects.\n\n## Table of contents\n\n- [Overview](#overview)\n  - [The challenge](#the-challenge)\n  - [Screenshot](#screenshot)\n  - [Links](#links)\n- [My process](#my-process)\n  - [Built with](#built-with)\n  - [What I learned](#what-i-learned)\n  - [Continued development](#continued-development)\n  - [Useful resources](#useful-resources)\n- [Author](#author)\n\n## Overview\n\n### The challenge\n\nUsers should be able to:\n\n- View the optimal layout depending on their device's screen size\n- See hover states for interactive elements\n\n### Screenshot\n\n![Screenshot of the page](./screenshot.jpg)\n\n### Links\n\n- Solution URL: [GitHub](https://github.com/paatre/nft-preview-card-component)\n- Live Site URL: [GitHub Pages](https://paatre.github.io/nft-preview-card-component)\n\n## My process\n\n### Built with\n\n- Semantic HTML5 markup\n- CSS custom properties\n- BEM naming convention\n- SCSS\n- Flexbox\n- Mobile-first workflow\n\n### What I learned\n\n#### Properly centering an element vertically to full viewport\n\nFrom last challenges, I noticed there were some problems with vertical centering of my `main` element. The element seemed to be fine when rendering the site. But when I started to zoom in, the upper part of the element was cut off. I didn't know why but then I started to research what was going on.\n\nAnd I found the exact problem! I had set `body` `height` as fixed `100vh` which meant that when I zoomed in, the height didn't take into consideration the content on the page which led to the `main` element being cut. I read more what could be the solution to the problem. On top of that, I found out using `100vh` with `height` introduces other problems as well with mobile screens and gradients (more of these problems in the [Useful resources](#useful-resources)). To all these problems, a solution was found:\n\n```scss\nhtml {\n  min-height: 100%;\n  display: flex;\n  flex-direction: column;\n\n  body {\n    flex-grow: 1;\n  ...\n  }\n}\n```\n\nThere are two parts:\n\n1. We need to set `html` *initial* height as 100%. But to make the page responsive when it renders content, not just the viewport height, we don't want to use fixed heights. That's why we set `min-height` as `100%`. With that, the HTML element can grow to be bigger than its initial size, but not smaller. `body` element gets the same initial size as the `html` has when the site is rendered.\n\n2. We want `body` element to be stretching as well! We have set `html` element as a flex parent and with that, we can set `body` element's `flew-grow` as `1` so that the `body` grows in the size when its parent, `html`, does.\n\nI'm not going to explain this solution as whole read. Go read the resource, it explains the matter really well! But I'm so happy I got this to work and I now know what was the problem and how to fix it!\n\n#### Overlay SVG icon with a background color on hover\n\nI did it! 🎉 I wasn't sure how to do the overlay for the card image when I started this challenge. At one point, I was going to do it with more elements than just the one `img` inside the container but I wanted to try to do it with the `::after` pseudo-element. I'm not sure if using `padding` the way I use it here to fill the icon's background was the best way to do it, but it's a way. Maybe there's something I could have done with the SVG photo itself or something. But all in all, the solution looks neat with the added transition.\n\n```html\n\u003cdiv class=\"card__image-container\"\u003e\n  \u003cimg class=\"card__image\" src=\"./images/image-equilibrium.jpg\" alt=\"A transparent cube standing on one corner\"\u003e\n\u003c/div\u003e\n```\n```scss\n\u0026__image-container {\n  position: relative;\n  border-radius: 8px;\n  width: 100%;\n  height: 100%;\n  overflow: hidden;\n  cursor: pointer;\n\n  \u0026::after {\n    content: url('../images/icon-view.svg');\n    display: block;\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    padding: calc((300px - 48px) / 2);\n    opacity: 0;\n    transition: opacity .5s ease;\n    background-color: var(--primary-cyan-transparent);\n  }\n\n  \u0026:hover::after {\n    opacity: 1;\n  }\n}\n\n\u0026__image {\n  width: 100%;\n  vertical-align: middle;\n}\n```\n\nBy the way, regarding `::after` and `::before` pseudos, they don't apply to *replaced elements* such as `\u003cimg\u003e`:\n\n\u003e Note. This specification does not fully define the interaction of :before and :after with replaced elements (such as IMG in HTML). This will be defined in more detail in a future specification.\n\nMore you know!\n\n#### Styling the hr tag\n\nOh yeah, if I want to style an `\u003chr\u003e` to be a really thin line, I need to remove its borders first and then add a background color. Otherwise, I can't see the style change.\n\n```scss\n\u0026__separator {\n  height: 0.5px;\n  margin: 16px 0;\n  background-color: var(--separator);\n  border: none;\n}\n```\n\n### Continued development\n\nI really need to check out the MDN reference for SVGs. Also, I want to understand all the nuances with `height` and `width` attributes.\n\n### Useful resources\n\n- [Stretching body to full viewport height: the missing way](https://dev.to/fenok/stretching-body-to-full-viewport-height-the-missing-way-2ghd) - The number one resource for me regarding vertical centering and stretching problems and how to tackle them.\n- [MDN: ::after](https://developer.mozilla.org/en-US/docs/Web/CSS/::after)\n\n## Author\n\n- GitHub - [@paatre](https://github.com/paatre/)\n- Frontend Mentor - [@paatre](https://www.frontendmentor.io/profile/paatre)\n- Twitter - [@teemuviikeri](https://twitter.com/TeemuViikeri)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaatre%2Fnft-preview-card-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaatre%2Fnft-preview-card-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaatre%2Fnft-preview-card-component/lists"}