Shirotech - CSS, Javascript, Node.js and Linux articles

:not(.active) vs overriding active class

There are times when you need to toggle classes with javascript. Perhaps it is part of a many items you would only want to show an active one amongst many. So you got this piece of javascript:

JavaScript
1
element.classList.toggle('active');

Makes you wonder when writing your bit of css, some would go for something like this:

SCSS
1
2
3
4
5
6
7
8
.item {
display: none;
border: 1px solid #ccc;

&.active {
display: block;
}
}

For me, I would prefer the inverseā€¦

Read More