2 ms·
> Absent this approach, in web projects of nearly any size, the CSS inevitably grows and becomes increasingly difficult to maintain. In web apps (as opposed to
by TimTheTinker 8y ago
> Absent this approach, in web projects of nearly any size, the CSS inevitably grows and becomes increasingly difficult to maintain.
In web apps (as opposed to web pages), this problem is better solved by breaking up and grouping CSS with its associated components. Re-use the components, not the CSS classes.
Regarding how to keep CSS modular, just give each component a unique name and apply styles to child elements using nested selectors:
.exampleComponent .exampleItem {
border: 1px solid #aaa;
/* etc */
}
This becomes even easier in SASS:
.exampleComponent {
/* put all the component's styles in here */
.exampleItem {
border: 1px solid #aaa;
}
}