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 using media queries/responsive design

Brian Marshall• 260

@bmmar

Desktop design screenshot for the NFT preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Found adding transparent view color overlay and icon very difficult. When I used position:absolute, the dimensions of the overlay were difficult to control. It looks as though it was using html as its containing block. I couldn't get it to use a smaller div as the containing block. Any ideas for how to do this??

Thank YOU!

Community feedback

Wendy• 1,670

@wendyhamel

Posted

Hi, nice solution!

The trick to the overlay and absolute positioning is that you have to position it's container. If you do not specify a container, your overlay should be positioned, it is positioned to the body, wich is the closesed positioned element. You can set it's container to display: relative.

I noticed the clock svg is not centered with the time left text.

I hope you manage to fix the problems with this guidence.

Happy coding!

Marked as helpful

1

Brian Marshall• 260

@bmmar

Posted

@wendyhamel Hi - thanks so much for commenting and the feedback.

Just one quick question - you say "if you do not specify a container" - how exactly do you specify a container?

0
Wendy• 1,670

@wendyhamel

Posted

@bmmar Yeah, I can see that's not a clear explaination.

An element with position="absolute" is positioned relative to its closest positioned ancestor. If the element, (the <div class="main-image"> in your case) is not positioned the browser will look for the next. The <body> is the containing block it will be positioned to. I hope this makes more sense, you can look at the MDN docs for more detailed explainations ans examples.

MDN docs about position

So to answer your question; you don't realy specify a container, but if you give the <div class="main-image"> a position of relative it will become the closest positioned relative.

0
Hamid Mahmood• 540

@Hamid210545

Posted

Hello ..... you have done an amazing job.... but let me correct you ... your card is not in center of the screen as per as design requirements.... but you can fix it by taking one simple step: by setting the properties of body tag { display: flex ; justify-content: center ; align-items: center ; } ............... I hope this will fix your problem............ Thanks!

0

Brian Marshall• 260

@bmmar

Posted

@Hamid210545 Hi - thanks so much for the feedback, but I don't see the problem - my card is dead centre - can you send a screenshot showing how it isn't?

Thanks

0
Hamid Mahmood• 540

@Hamid210545

Posted

@bmmar okk ... i will send the screenshot ... but give me your emaill so i can send it to you .... Thanks! and can you please give me your whatsapp number ... i want to make you my friend ....If you wish???..... Thanks !

0
P

@Fanushhh

Posted

@bmmar While the card is aligned horizontally, it is not aligned vertically. With the code sent above by Hamid, he's actually giving you keys to align both vertically and horizontally. As a side note, justify-content: center aligns items horizontally, align-items:center centers items vertically, which is what you miss in your code.

0
Hamid Mahmood• 540

@Hamid210545

Posted

@Fanushhh Thanks! for clearing my point to @bammer .... thanks a lot!

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