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

Next js framework with Tailwind CSS

next, tailwind-css
anneelv•10
@anneelv
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


It is difficult to manage the div tag and what kind of tailwind css attribute should I use so that is shows the same as the preview. I am unsure about the image part where if the screen size is small then show the mobile version else just show the desktop version. I am struggling on how to code it correctly. Another thing that I failed to do is to re-position the smaller price to be in the middle height of the bigger one. I didn't find the solution for it.

I heard from my friend that it is bad to use a lot of div tag. Then if it is bad how should I style it?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Kevin Bautista•40
    @henixK
    Posted almost 2 years ago

    When it came to handling the images, my approach was to place both of them inside an image container. To ensure the mobile image is only visible on mobile devices, I used the md:hidden class to hide it by default, and then applied the block class to display it properly. Conversely, for the second image, I reversed the process. Initially, I applied the hidden class to hide it, and then used md:block to make it visible on medium-sized screens and above.

  • Clémence Tafforeau•110
    @ClemenceTafforeau
    Posted almost 2 years ago

    Hi! 👋 From my understanding, it is considered best practices to use semantic HTML instead of divs ; that is to say, use elements that have intrinsic meaning instead of just meaningless containers. This article might help you ! Happy coding 👍

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