Use CSS Variables Almost like Boolean Values with Calc

InstructorJhey Tompkins

Share this video with your friends

Send Tweet

In this lesson, we explore how you can use CSS variables almost like Boolean values in combination with calc().

By setting a variable to 1 or 0 and then using logical operators, we can abstract and decouple areas of our CSS. This can ease maintenance when our CSS starts to get complicated. In this example, we walk through how a variable could be used to dictate part of an element's transform.