DEV Community

Discussion on: Conditional logic with CSS – The CSS custom property trick.

Collapse
 
afif profile image
Temani Afif

Your example is a bit overkill for a basic task. You can simply do the following: jsfiddle.net/4k9aj0zc/1/ .. you don't really need to make it complex with the empty var trick.

Collapse
 
siddharthshyniben profile image
Siddharth • Edited

That is a nice approach, but it's almost similar to directly setting the property like background-color: ... in the media query.

This is a basic demo but I added the complexity for understanding. I don't want people wondering "where did this undefined variable come from" etc.