CSS => Too Good ✅ | Pt.2

I'm back again complaining about CSS. My last post a while ago helped me a bit but I'm still stuck with something. I'm currently creating my own App and still struggle with a few things such as units, rules and accessibility. I don't know know which units to use for what and what I have to consider with my design and technique. I'm still thinking about using Bootstrap. But with Bootstrap comes alot of trash and code breaking stuff. I've already built my own HTML structure and if I try to switch to Bootstrap now much stuff will break (probably) and you can't really customize stuff that well with Bootstrap aaaaannnddd its outdated! Summary: My head goes boom 💥
28 Replies
Jochem
Jochem4mo ago
So what's your question exactly? If you give some examples, folks can try to suggest what units to use Also https://whatunit.com/
CodeMoon07
CodeMoon07OP4mo ago
To be honest I don't really know myself. I'm just really struggling. I'm gonna go on a break rq. My head is about to explode.
ἔρως
ἔρως4mo ago
what exactly are you struggling with?
Mannix
Mannix4mo ago
what is so outdated about Bootstrap?
CodeMoon07
CodeMoon07OP4mo ago
for now i think i will just deactivate my CSS and only focus on the functionality first is it the right decision?
ἔρως
ἔρως4mo ago
yes
Jochem
Jochem4mo ago
@CodeMoon07 the recommended time to be stuck before asking for help is 15-30 minutes. Maybe make it 45 cause answers here take a while sometimes... But "my head is about to explode" is hours too late
ἔρως
ἔρως4mo ago
make it work, make it good, make it fast if it isn't working, don't try to make it good because it won't be
CodeMoon07
CodeMoon07OP4mo ago
im sorry i just got some food im here now
13eck
13eck4mo ago
My advice for people new to CSS and it's wide variety of units hasn't changed in years, so here it is: * Are you sizing font? Use rem. This avoids compounding issues you get with em * Are you sizing space (margin/padding)? Use em. This allows bigger things to have more space * Are you sizing visual flourishes (border, inset, offet, etc)? Use px. It doesn't matter what their screen size is as it's just to look nice * Are you sizing an image? Use max-width: 100%;. This prevents them from being too big and getting pixelated * Are you sizing text? Use ch. This gives a better mental model as it's practically a character width
CodeMoon07
CodeMoon07OP4mo ago
what about widths and stuff
13eck
13eck4mo ago
What about them? "Width" is too vague. What are you sizing the width for? Images? Text?
CodeMoon07
CodeMoon07OP4mo ago
widths for cards or input fields
13eck
13eck4mo ago
You need to know why you're setting a width, not just that you are setting one Cards are textual, right? So use ch b/c that's what I recommend for text Input fields? Same. It's text
CodeMoon07
CodeMoon07OP4mo ago
so anything text based i should use ch and sizing text rem
13eck
13eck4mo ago
font-size should be in rem, widths for text elements should be in ch So your h1s should be 2rem, and h4s should be 1rem. Your text input should be appropriately sized. So if you're looking for a word or two then 40ch should be plenty wide
CodeMoon07
CodeMoon07OP4mo ago
Isn't
px
px
better for margin and paddings? cause why should it be relative to 16px if it doesnt have to do anything with text
ἔρως
ἔρως4mo ago
depends on what you want, but both are valid
Jochem
Jochem4mo ago
em will grow with font size adjustments, px will not. So generally, paddings for stuff like buttons and other text-containing elements you would go with em,
CodeMoon07
CodeMoon07OP4mo ago
so paddings and margins with em if the same element is text based and for layout margins and paddings px right?
Jochem
Jochem4mo ago
I'd recommend following https://whatunit.com Kevin made it but yeah, that works...
CodeMoon07
CodeMoon07OP4mo ago
well if its from kevin i will follow that chart kevin is the CSS king 👑
13eck
13eck4mo ago
No. When starting out stick with em for margin/padding. Bigger text needs more space than smaller text. When starting out stick to the simple rules. Brach out when you know more. Don't overcomplicate things. Know the basic rules before you get fancy.
CodeMoon07
CodeMoon07OP4mo ago
FINALLY I understand CSS Are yall happy or not? 😔
Jochem
Jochem4mo ago
are you being sarcastic? I'm really not sure what you're trying to achieve by venting here, rather than using the space as the valuable resource it can be whenever you're stuck like, way before your "head is going to explode"
CodeMoon07
CodeMoon07OP4mo ago
Sorry for my behaviour. I thought it's a bit more chill in here. But yeah. The problem is solved and I will become the next CSS king (hopefully)
Jochem
Jochem4mo ago
you're fine, but like... I don't get why you stay stuck until frustration when folks here are more than willing to help, and then just come here to vent when you're so frustrated you have to step away from your PC. You could save yourself that frustration and learn so much quicker if you just asked direct questions with code examples but you do you 🤷
CodeMoon07
CodeMoon07OP4mo ago
Thank you for you guys's help! 😁

Did you find this page helpful?