DEV Community

Cover image for 10 CSS Tricks for UI developers

10 CSS Tricks for UI developers

Niraj Narkhede on November 19, 2024

Introduction: Elevating Your CSS Game Hey there, fellow UI developers! Are you ready to take your CSS skills to the next level? Whether ...
Collapse
 
alex__ca638de1ec30 profile image
Alex Maltsev

Why are common things called tricks and hacks?

Collapse
 
mark_kimitch_b168cb8241ef profile image
Mark Kimitch

For the clicks... obvi.

Collapse
 
spiritfox358 profile image
spiritfox358

hahaha, I also have same doubt

Collapse
 
nnnirajn profile image
Niraj Narkhede

Its Depends upon experience, for beginners its Tricks, for experienced its common things.

Collapse
 
johnmunsch profile image
John Munsch • Edited

Good article. I recognize that you're probably constrained by what you can show on a page on Dev.to, but maybe next time screenshots of the applied styles accompanying each would be great or even a link to an interactive page deployed to GitHub or one of the online sandbox sites would give it even more pizzaz.

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thanks ! I am glad you like it.

Collapse
 
kirit_makwana_85d93c0ed13 profile image
kirit makwana

Yes, Better to provide a link for demo of the snippets

Collapse
 
nnnirajn profile image
Niraj Narkhede

Sure

Collapse
 
melnik909 profile image
Stas Melnikov

Hey @nnnirajn!

A lot of pure CSS solutions have huge problems. For example, pure CSS tooltips from your article.

The :hover pseudo-class matches when user hover on an interactive element. But it stops matches immediately when users make the cursor away.

Users with tremor will see infinite flashing. It's why the good solutions is to add a few seconds delay with JS.

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thanks for the suggestion !!

Collapse
 
hbthepencil profile image
HB_the_Pencil

This is a neat article, but I wish there was a bit more detail, especially at the beginning (things like Flexbox don't have a ton of documentation in the article). Overall, though, these are good tips, and I would love to use the tooltips especially someday.

Collapse
 
nnnirajn profile image
Niraj Narkhede

I am glad you like it !!

Collapse
 
kdankov profile image
Konstantin Dankov

No need for the input trick for accordion anymore. We have details and summary tags with name attribute to manage open state across multiple elements. It is also possible to do native css animations on height and display properties

Collapse
 
thefinn15 profile image
Timur

Dude, why most of things in the article its common "tricks" from similar articles as "How to learn CSS in 2024 for beginners" ? And why you aren’t talking about media queries or custom select input with cross-browsing ? If we are talking about "super advanced tricks hacks" 😂

Collapse
 
nnnirajn profile image
Niraj Narkhede

I will try to write an detailed article on media queries and custom select input with cross-browsing.

Collapse
 
shikkaba profile image
Me

This article isn't really tricks. These are all common CSS.

Collapse
 
nnnirajn profile image
Niraj Narkhede

Its Depends upon experience, for beginners its Tricks, for experienced its common things.

Collapse
 
john_smithappdev_5a63a71c profile image
John smithappdev

"Wow, this is an incredibly well-structured and insightful post! Thank you for sharing such practical CSS tricks – I especially loved the sections on CSS variables and Flexbox. They’re such game-changers for simplifying and maintaining stylesheets.

The example with the pseudo-elements for a quote block is so creative – I've been meaning to experiment with them more. The CSS-only accordion idea is also brilliant! It's amazing how much can be achieved without JavaScript these days.

Do you have any favorite resources or tools for experimenting with CSS shapes or creating cross-browser custom scrollbars? Those are areas I’d love to dive deeper into.

Thanks again for this amazing breakdown. Looking forward to seeing more from you!"

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thank you so much for your comment !!

Collapse
 
procoders profile image
ProCoders

Thank you!

Collapse
 
mkastner profile image
mtkastner

For accordion you can use summary and detail tags which also make for better semantics and accessibility.

Collapse
 
nnnirajn profile image
Niraj Narkhede

Yup we can use detail tags also

Collapse
 
madeinmilwaukee profile image
Chuck Watson • Edited

I agree, there is no need to "hack" with css. See the spec

Thread Thread
 
nnnirajn profile image
Niraj Narkhede

Its Depends upon experience, for beginners its Tricks, for experienced its common things.

Collapse
 
nnnirajn profile image
Niraj Narkhede

I am glad you like it

Collapse
 
fredg_prod profile image
Frédéric G. (FredG_ProD)

A great cheat sheet !

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thank you !!

Collapse
 
affaan_aulia_786 profile image
Affaan Aulia

Wow CSS

Collapse
 
nnnirajn profile image
Niraj Narkhede • Edited

Thank you !

Collapse
 
jangelodev profile image
João Angelo

Hi Niraj Narkhede,
Top 5, very nice and helpful !
Thanks for sharing.

Collapse
 
nnnirajn profile image
Niraj Narkhede

I am glad you like it.

Thank you !!

Collapse
 
kutubu1 profile image
Abdul Wadudu Shaibu

Very helpful 👍

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thank you !!

Collapse
 
alexus85 profile image
Alex Petrik

great article, although it'd be great if you also provided a visual illustration to each example.

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thank you !!

Collapse
 
bobbyleex profile image
BobbyleeX

Awesome,Great article.

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thank you !!

Collapse
 
_aliraza profile image
Ali Raza

Great article and nice tips. Thank you

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thanks you !!

Collapse
 
chief_dakwa_3c6a8260688db profile image
Chief Dakwa • Edited

Great tips. Thanks

Collapse
 
nnnirajn profile image
Niraj Narkhede

Thank you !!

Collapse
 
jrohatiner profile image
Judith

Thank you. Very very useful demo. 👍🏼

Collapse
 
on3dd profile image
Artyom

Totally useless unless you're a complete newbie.

Collapse
 
nnnirajn profile image
Niraj Narkhede

It means it totally useful for newbie.