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

nft-preview-card-component using flex

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

Solution retrospective


How much flex is too much?

CSS flex provides an elegant way to solve a lot of layout problems but sometimes I wonder if I tend to use it too much. If you look into the part with the diamond icon and the clock icon you will notice that instead of using flex again I decided to go with the position property. But I'm not sure if this is the right thing to do here.

What would you do? I'd be grateful for any advice.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Alper•1,090
    @adonmez04
    Posted almost 2 years ago

    Hi, @rsacharias. That's a good solution. Keep coding. Here are some important tips.

    1 - You have to use some resets to fully control the box model. Use this ruleset for this basically:

    *, *::before, *::after {
      padding: 0;
      margin: 0;
      box-sizing: border-box;
    }
    

    You will find many other good CSS resets on the internet, such as joshwcomeau's and Andy Bell's

    2 - You don't need to declare any values for the width property of your elements. You can use max-width instead of width.

    3 - You can use vertical-align: middle; to align your elements vertically. For example:

    .assets .icon {
      vertical-align: middle;
    }
    

    Sometimes, we use so much flex properties for our elements. It's totally normal. To keep it simple this status, we can create some flex classes and we use these styles from HTML as a class. You will see some classes in HTML flex, flex-col- flex-row etc. You can try this style when you are considering using that much flex for your elements.

    I hope these will help you. Keep coding and have a wonderful day.

    Marked as helpful
  • P
    Alper•1,090
    @adonmez04
    Posted almost 2 years ago

    @rsacharias Organizing your CSS It looks like a good resource, I have been trying to find something like this for a long time, thanks.

    I checked your code and it looks more legible and consistent now. That's an improvement. We won't get our perfect code the first time. We need to improve our code with each version of the solution. Step by step, at some point, we'll have our perfect code.

    I highly recommend solving your challenges over and over again. You can create a new repo and give it a new version name like v2.0 etc. That way, you can compare your first version with the latest version of the project. And you'll see your process clearly.

    Another thing is this ruleset:

    html {
      font-size: 16px;
    }
    

    You don't need to declare this. The font-size is equal to the browser's default (and it's mostly 16px, but it's a computed value, not a present value), and it can be set by the user. If you declare 16px in CSS, you break this HTML behavior. Allow the browser to set this value to the user's preference.

    Keep coding and have a wonderful day.

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