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

Preview-card component ( Mobile / Desktop layout )

accessibility
Handyyweb•120
@HandyyWeb
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


There is still some bugs in the code and it's not fully finished, if you have some finitions to provide me, I will be happy to receive it.

I don't know if it's fully responsive, especially about my using of units (em,rem,px,etc...)

If you have any advice, don't hesitate to give them to me.

Thank you and have a great day !

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted about 2 years ago

    Hi

    Here is feedback I've made in browser devtools. Go through each item in turn and look things up as and when you need to.

    I hope this helps you :)

    
    /* Element | https://handyyweb.github.io/Preview-card/ */
    
    body > main:nth-child(1) {
    /* word-wrap: break-word; */
    }
    
    /* index.css | https://handyyweb.github.io/Preview-card/index.css */
    
    @media only screen and (min-width: 600px) {
    main {
    /* max-width: 150%; */
    /* min-height: 50%; */
    max-width: 45rem;
    note: media queries should always be defined in rem or em;
    display: flex;
    }
    /* div.image { */
    .image {
    /* float: left; */
    /* padding: 0; */
    }
    /* div.content { */
    .content {
    /* float: right; */
    /* padding: 2rem 1rem 0rem 1rem; */
    padding: 2rem;
    filter: ;
    display: flex;
    flex-direction: column;
    }
    div > p {
    /* padding-top: 2rem; */
    margin-top: 2rem;
    }
    }
    
    main {
    /* min-height: 35rem; */
    }
    
    div {
    /* max-width: 20rem; */
    }
    
    /* div.content { */
    .content {
    }
    
    button {
    /* margin-top: 1rem; */
    /* bottom: 4px; */
    margin-top: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1ch;
    cursor: pointer;
    transition: all 0.3s ease-out;
    note: Use the colors from the style guide. I think you may be using a hover color here;
    }
    
    div > small {
    /* padding-top: 5px; */
    /* letter-spacing: 6px; */
    letter-spacing: 0.4em;
    note: dont use complex css selectors like this unless you absolutely have to. Use single class selectors. Keep CSS specificity low!;
    note: Small is not a meaningful element on its own. It should be inside a paragraph;
    note: Letter spacing MUST NEVER be in px!;
    note: define font size explicitly in rem;
    }
    
    body {
    note: I don't think fonts are being correctly applied in this solution. Check them';
    }
    
    div > h1 {
    /* padding-top: 1rem; */
    margin-top: 1rem;
    note: I think you are confused between padding and margin. Look up the differences. Margin is for _external_ spacing between elements, padding is for _internal_ spacing inside elements (like boxes);
    }
    
    div > p {
    /* padding-top: 1rem; */
    /* padding-bottom: 1rem; */
    /* line-height: 26px; */
    margin-top: 1rem;
    line-height: 1.6;
    note: Line height must NEVER be in px;
    note: generally on child elements you'll only want margin to go in one direction (top in this case)';
    }
    
    span.price {
    /* margin-top: 3rem; */
    margin-top: 2rem;
    note: You MUST use meaningful elements on this. Both prices should be wrapped in a paragraph set to display flex;
    note: Dont use key words for font weight. Use the exact value eg 700 or 800 or whatever the weight is you've downloaded';
    display: block;
    }
    
    span {
    /* padding: 1em; */
    /* width: 100%; */
    note: don't use inline styles';
    }
    
    del {
    note: Screenreaders need additional visually-hidden information to identify this as the old price;
    note: use colors as defined in the style guide;
    margin-bottom: auto;
    }
    
    svg {
    note: this svg needs 'aria-hidden="true" focusable="false"' added to it so the svg is treated as decorative by all screenreaders;
    }
    
    .image img {
    height: 100%;
    note: place a class on what you want to style;
    object-fit: cover;
    }
    
    

    I've done a post about the html on this challenge, which may help you when I mention meaningful elements and informing screenreaders about the prices. There are other posts on there about font property units etc if you want to look around

    Marked as helpful
  • Rostyslav Nazarenko•560
    @rostyslav-nazarenko
    Posted over 2 years ago

    I'm only a beginner but played with your code for a bit and I have a few suggestions.

    • add box-sizing: border-box with this you'll fix divs splitting in different conners.
    html {
      box-sizing: border-box;
    }
    
    *,
    *::before,
    *::after {
      box-sizing: inherit;
    }
    
    • I would increase the breakpoint from 24rem to something around 600px so it wouldn't be so compressed
    Marked as helpful
  • Sameer Md•540
    @Sameermd16
    Posted over 2 years ago

    Card component is not responsive between 375px to 706px. Try making making responsive by adding media queries in the format @media only screen and (min-width: 376px) and (max-width: 706px) { "here comes css" }

    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 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

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub