@asbhogal
Posted
Hi there,
This is a good attempt, and I can see why you've used certain code. I've made several suggestions below when you refactor this:
- Avoid using the
absolute
to position this card and instead useflex
properties (ie.display: flex
;flex-direction: column
) andmargin: 0 auto
to centralise it - You can style the
body
parent element of the card by also usingflex
properties andheight: 100vh
to vertically center the card (height: 100vh display: flex; flex-direction: column; justify-content: center;
) - You should set a
max-width: 320px
, for e.g., on the parent container, and awidth: 100%
, which means any value above320px
will keep it fixed at that, and any width below will take up the full length (remember to convert thesepx
torem
values) - Remove the
max-width
property on the childimg
element and replace this withwidth: 100%
. You also won't need themargin
property. - You can remove the
.img-block
element as this doesn't serve a purpose here (presumably this was to be the parent container which wraps theimg
? Either way you can remove this) - Use a CSS reset which removes all pre-set styling browsers add to web pages, which can cause cross-browser inconsistencies. Here's a good modern one which is recommended Link
- It's best to use explicit (ie.
rem
) units for positioning elements, instead of%
because these are more variable and prone to cross-browser responsiveness issues
Hope this helps!
Marked as helpful
@rdonatiello1
Posted
@asbhogal Very helpful. Thanks so much!