Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Product preview card component - HTML / CSS

BT738844 600

@BT453567

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


What are you most proud of, and what would you do differently next time?

Getting my project very close to the design pictures.

What challenges did you encounter, and how did you overcome them?

Working with the flex boxes ensuring they worked how I wanted.

Spent time reading about the different flex box settings and then applied with some trial and error.

What specific areas of your project would you like help with?

Would like to know how my code compares to professionally written code.

Community feedback

@0xabdulkhaliq

Posted

Hello there 👋. Congratulations on successfully completing the challenge! 🎉

  • I have a suggestion regarding your code that I believe will be of great interest to you.

CSS 🎨:

  • Looks like the component has not been centered properly. So let me explain, How you can easily center the component without using margin or padding.
  • We don't need to use margin and padding to center the component both horizontally & vertically. Because using margin or padding will not dynamical centers our component at all states
  • To properly center the component in the page, you should use Flexbox or Grid layout. You can read more about centering in CSS here 📚.
  • For this demonstration we use css Grid to center the component.
body {
    min-height: 100vh;
    display: grid;
    place-items: center;
}
  • Now remove these styles, after removing you can able to see the changes
.card-container {
  margin: 200px auto;
}
  • Now your component has been properly centered

.

I hope you find this helpful 😄 Above all, the solution you submitted is great !

Happy coding!

0

BT738844 600

@BT453567

Posted

Hello @0xabdulkhalid

Thank-you for the feedback.

I presume that would just be for the desktop view? Would you say the mobile view remains the same with margin on top and auto margin at the sides?

Regards

0
BT738844 600

@BT453567

Posted

Hello @0xabdulkhalid

I have found that the main tag, as it is directly within the body, is directly affected by the place-items center, and therefore this affects the alignment of my main div.

If i remove the main tags it works fine. Is there a way to mitigate the issue with the main tags?

Thanks

0

@0xabdulkhaliq

Posted

@BT453567,

  • "I presume that would just be for the desktop view? Would you say the mobile view remains the same with margin on top and auto margin at the sides?", Actually we can smartly utilize Margin property along with Grid.
  • You need to remove all margins and paddings from the component, in your case for mobile view you can remove the margin on top and auto margin on sides and then you need to apply vertical padding for body like padding: 1rem 0 along with margin of 0 1rem and max-width of 36rem or somethings due this changes you don't need to write styles seperately inside media queries.
  • "If i remove the main tags it works fine. Is there a way to mitigate the issue with the main tags?", The issue is actually lies on unwanted nesting of div inside of main. You need to directly add .left-column & .right-column as direct child to main.
  • Like this,
<main>
      <div class="left-column"></div>
      <div class="right-column"></div>
</main>
  • Removing main from markup will only results in accessibility issues, instead we can purge unwanted elements.

Hope this feedback helpful to you!

Marked as helpful

0
BT738844 600

@BT453567

Posted

Thanks Abdul @0xabdulkhalid, some useful information there.

0

Please log in to post a comment

Log in with GitHub
Discord logo

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