Design comparison
Solution retrospective
I encountered some trouble getting an <a> tag to style how I wanted (couldn't set its width to 100% of the parent) so I went with a <button> despite the potential accessibility problems. Did anyone else encounter this? Ideas for a workaround?
This was the first time I've used vh and vw for mobile scalability across all devices before switching to rem and em for desktop. Is this advisable? Is there a better practice?
I also tried a different tact with the ordering in my CSS. Any good? I do feel like it could be a little confusing for the proverbial "next developer in line" but I wanted to try it. Is it better practice to apply more specific classes?
Cheers, Arun.
Community feedback
- @mattstuddertPosted over 4 years ago
Hey Arun, awesome work on this challenge. Your solution screenshot is basically like-for-like with the design! π
For the width issue, I'm just guessing but did you change the
display
property toblock
? You'd need to do this to get it to fill the parent. Ordisplay: inline-block
andwidth: 100%;
.Using
vh
andvw
too much can lead to some tricky situations. I'd recommend only using them rarely for very specific situations. I typically userem
units for things likefont-size
,padding
,margin
, and others. If it's a column I'll use either%
units,fr
units if I'm using Grid, orflex-grow
orflex-basis
for Flexbox.The way you've written your CSS is fine! The only thing I'd recommend doing is reviewing the breakpoint at
500px
. When it first switches there isn't enough space on the screen. So you could increase it a bit to make sure the content always fits.I hope this helps. Let me know if you have any questions!
1@arun-robertsPosted over 4 years ago@mattstuddert
Thanks!
Yep, just tried changing
display
toblock
on ana
tag. Fixed it. I'll usea
tags from now on.What kind of tricky situations? I tried searching but all I found were the old compatibility issues and they seem to be mostly fixed now. Even on IE. I can see now why I went for
vh
andvw
though. I was explicitly setting thefont-size
to15px
on mybody
even on mobile view, sovh
andvw
were the only way I could get my layout to look good across all devices. I'm guessing every device has its own root font size so that1rem
changes size across devices?Excellent news. I've just learnt about BEM so I might try that for the next couple of projects, too. As for the breakpoint, thanks for picking me up on it. I saw it but I foolishly assumed no one would be trying to view the site below 600px anyway. I'll fix it in the next challenge.
Thanks for the tips and feedback!
1@mattstuddertPosted over 4 years ago@arun-roberts you're welcome!
For
vw
, it only looks at the viewport width and so you can get into issues where a child element can overflow its parent if you're usingvw
to set thewidth
.For
vh
, I'd recommend not using it to set theheight
of elements, unless you specifically want it to be 100% of the viewport or something like that. I see people usingvh
to set theheight
ofsection
or other elements when they don't need to. This can cause issues whereby a user with their browser window set to be wide but short in height can't see some of the content because it starts to get squashed vertically.So I'd only recommend using them for extremely specific reasons and not as a common unit.
1@arun-robertsPosted over 4 years ago@mattstuddert
I see what you mean now. I was excited by
vh
but I see now they're not quite as universally scalable asrem
/em
.Super interesting.
Thanks again!
0@mattstuddertPosted over 4 years ago@arun-roberts no problem! Theyβre great in very specific instances. But not for liberal use π
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