There are a lot of discussions about CSS vs. JavaScript and the battle is getting seriously once CSS is adding a bunch of amazing features and it's...
For further actions, you may consider blocking this person and/or reporting abuse
How about an ancient feature that has worked since the IE6 days but has rarely been used? :D
Very useful for long breadcrumbs, and on desktop you rarely get the scroll as you do have the screen estate.
I haven't encountered this trick in the wild. Or if I have I have already forgotten about it :)
Thank you for sharing this solution. It's really helpful!! ✌
Most of the stuff i used but darkmode was new for me and a good tool for my arsenal. It was good read. Kudos
Awesome! Using just CSS we are able to handle Dark mode easily! 👌
Yes!
About
scroll-behavior
: I'm sure most of us are excited about it, but remember that it doesn't come without problems. Specifically:prefers-reduced-motion
media query to meet their needs.In short, consider doing something like that:
(Written like this, it's safe for those browsers that don't support
prefers-reduced-motion
.)I'm with you Massimo, good tips. There are a lot of interesting CSS features, but we need to think about when and how to use them correctly. 🤩
Great article, Diogo, I love little tips like this that get lost or that you never knew existed.
Thank you Rob! 👍
Lovely, but just wanna point out on
position: sticky
you cannot have a parent that has attr overflow hidden to be applied otherwise it doesn't work...
scroll-behavior: smooth; is not supported in Safari, so you have to use JS ;)
I agree with you that for some browsers JS is necessary depending on the feature 😢🤷♂️. But for most of modern browsers we no longer need JS anymore for a lot of new CSS features. 🎉
... or let it gracefully degrade in Safari.
It's not something that would break the UI 😉
I feel happy that this article was useful for you! There are a lot of solutions for handling Dark theme, but just using CSS you can do a lot of thing easily! ✨🎉😎
postcss-dark-theme-class can make even a dark/light switcher with CSS-only dark theme (and 5 lines JS for switcher).
Lovely stuff. CSS is amazing. I always feel like the less JS a page uses the quicker it’ll be to load and use, but I have no idea whether that has any basis in fact.
I think you're right. In general, CSS can increase the performance a lot when compared with JS. So, every time you can, go ahead with CSS. :)
Thanks! It's really helpful.
You're welcome! Thank you for your feedback! :)
Thanks, great article, Diogo, I love the tips and i really find it helpfull in increasing web performance (since it implies less js scripts)
You get it. That's the idea: less JS and better performance! 🤩