Design comparison
Solution retrospective
Hello, My second challenges :) I use px and % for set the size. What's the best practice please? i've add responsive rules, if you have advices i appreciate. Thank you Vincent
Community feedback
- @vanzasetiaPosted almost 3 years ago
👋 Hi Vincent Ferraro!
Regarding your question:
- Using
px
is not accessible at all since it is an absolute unit. Usingpx
is obviously a bad practice it won't allow the user to scale the size of any elements on the page. So, I would recommend usingrem
unit most of the time.rem
unit is a relative unit, which means that it can adapt through different scaling. - For the percentage unit, it is relative or depends on the situation. But most of the time you will use
rem
orem
unit instead of%
.
Feedback:
- Accessibility
- Create a custom
:focus-visible
styling to any interactive elements (button
, links,input
,textarea
). This will make the users can navigate this website using keyboard (Tab
) easily - For any decorative images, each
img
tag should have emptyalt=""
andaria-hidden="true"
attributes to make all web assistive technologies such as screen reader ignore those images. In this case, all images are decorative only. - Every page should have one
h1
as an identifier. In this case, you can increase the heading level ofOrder Summary
. - All page content should live inside a landmark (
header
,main
,footer
). In this case, you can wrap all page content withmain
tag, except your attribution. For your attribution, you can swap thediv
withfooter
tag.
- Create a custom
- Important
- You should always include
box-sizing: border-box
as your common reset styling. This property will solve a lot of problems! See the demo on CSS Tricks.
- You should always include
- Visual
- On mobile view (360px * 640px), the card having full width. Prevent this by adding
padding
tobody
element. - On mobile landscape mode, the card gets cut off. The problem is you're limiting the height of the
body
element, it will not allow the users to scroll the page if the page content needs moreheight
. Usemin-height
instead. - You're only using the desktop pattern image for the
body
background. You should use the mobile version for mobile and change the pattern image by using@media
query. - I would recommend applying these styles to your
body
element.
- On mobile view (360px * 640px), the card having full width. Prevent this by adding
body { font-family: 'Red Hat Display', sans-serif; /* Remove this property since by default body element has 100% */ width: 100%; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; background-image: url(/images/pattern-background-mobile.svg); background-size: 100%; background-repeat: no-repeat; background-color: <blueish-color>; } @media (min-width: <value>) { body { background-image: url(/images/pattern-background-desktop.svg); } }
That's it! Hopefully, this is helpful!
3@vincentferraroPosted almost 3 years ago@vanzasetia Hello Vanzia, thank you very much for your amazing comments and your help. Most valuable for me. I'm going to take you advice and revise my files. :)
0 - Using
- @Chris94LeePosted almost 3 years ago
Hey Vincent, looking good!
One thing I noticed is that you're missing a background colour. What I'd do is add
background-color: #E0E8FF
to yourbody
in the CSS file. Also, to make the background image fit like the designs, you can addbackground-repeat: repeat-x;
and then remove thebackground-size
style you have on the body. Let me know if this works for you!Also regarding px for size, I try to avoid pixels for accessibility reasons, and tend to stick to either em or rem. Check out: https://engageinteractive.co.uk/blog/em-vs-rem-vs-px
Looking forward to seeing your future work!
1@vincentferraroPosted almost 3 years ago@Chris94Lee Hello Chris, Wohaa Thank you for your advices! I'm going to read your article. :)
0
Please log in to post a comment
Log in with GitHubJoin 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