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

Endo_hr 60

@EndoHr

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


During this challenge, I faced too many questions and problems. If you r able to answer, please help me to figure.

  1. To centering that card, I used position: relative (left, top). But I think it's not good idea to do responsive thing. I thought I had to use display: flex then (justify, align to center). But when I did that I don't know my align-items didn't work, so I just Googled and found I had to set the height of the card 100%, but to do that, I can't use border-radius (cuz my height is now 100%). I had more problems, but this one is the hardest one to figure.

Community feedback

Hassia Issah 50,810

@Hassiai

Posted

Replace <div class="cart"> with the main tag and <h2 class="product_name"> with <h1> to fix the accessibility issues

To .cart on the page, add min-height:100vh; display: flex; align-items: center: justify-content: center; or min-height:100vh; display: grid place-items: center to the body. Instead of giving .cart position: relative and its properties.

Give .cart a fixed width value instead of a percentage width value

Use rem and em as unit for the padding, margin and width values instead of percentages and px for more on CSS unit watch this https://youtu.be/N5wpD9Ov_To

Hope am helpful. Happy coding.

0
faizan 2,420

@afaiz-space

Posted

Hey @EndoHr, congratulation on completing the first challenge.

add

body {
    /*background-color: hsl(30, 38%, 92%); */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

remove position left and top property from cart class.

.cart {
    /* position: relative; */ 
    /* left: 28%; */
    /* top: 80px; */
    display: flex;
    border-radius: 10px;
    width: 35rem;
    flex-direction: row;
    overflow: hidden;
}
  • remove height and replace width:21%; with width:50%; in the .perfume class.
  • replace width:21%; with width:50%; in the .details class.

remove top and left property from the media cart class.

@media only screen and (max-width: 600px)
.cart {
    /* top: 10px; */
    flex-direction: column;
    /* left: 5%; */
    width: 100%;
}
  • replace /* width: 90%; */ with width: 100%; in the media .perfume_mob class.
0
S MD suleman 3,530

@sulemaan7070

Posted

hey Endo_hr😄 Firstly I congratulate you on completing the first challenge,I see you are having a problem, you can make whole body as flex.

  1. you can try
display:flex;
align-items:center;
justify-content:center;
}``` .This will the whole `cart `-div centered.

2. and for the `details-div` you can use the
 ```.details{
display:flex;
align-items:center;
justify-content:space-between;
}```. along with some padding. I hope this helps and let me know if you need any further assistance💯.. happy coding🔥
0
Revin 280

@revin212

Posted

Hello, nice job for finishing the project!

You can center the card using "display: flex" on your body tag, "justify-content: center", and "align-items: center".

use width:50% for the image and the description, and then, set the card max-width to 500px. Your problem is, the image and description didnt fill all the space (100%) of the div "cart" class.

for the border-radius problem, this might help you:

use "overflow: hidden;" on the card element (in your case, the div "cart" class).

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