Managing ever-growing CSS stylesheets at server-side - are there any libraries, helpers?
When developing large application using ASP.NET (MVC or classic, doesn't matter), especially in large team, it is easy to produce a lot of messy, non-traceable CSS definitions. After some time we can end up not knowing why particular definition exists and what is its real effect considering style inheritance and cross-browser differences. Needless to say, changing anything in that mess is a risk and there are hundreds of ways how small change could affect the system.
I know some solutions to organize CSS stylesheets better, like predefined CSS "frameworks" or DotLessCss engine, but I still find it quite hard to cope with CSS as there is no such r开发者_运维技巧elationship between HTML markup and CSS styles like i.e. between interface and concrete class in C# code. I know this is by design to make presentation separate from the structure, but I believe it might be useful to have such a correspondence at development level.
Ideally, I need something that can enforce the team not to make messy CSS or be able to clean that mess up automatically. Do you know any resources that may help me, or any guidance how to manage my CSS definitions easily?
Let me ask for something a bit different:
Despite of my several years of web experience, I believe I would feel much more confident if some of my CSS could be moved into C# code, the same way as some of HTML generation is done by MVC HTML Helpers. It saves me writing a lot of unnecessary markup, still allowing to do so if needed. And it is more unit testable, easier to refactor using tools like ReSharper etc.
I don't need mergers and compressors of my CSS, I would like to be able to manage my CSS at declaration level.
Maybe there are some tools like that I'm not aware of, or maybe that idea is just wrong and wouldn't be useful?
The Firefox plugin Dust Me Selectors should help to clean up unused selectors.
That being said please read What's Wrong With CSS
P.S: Please make reading Jeff Atwood's blog a habit :)
It might be worth looking at how Telerik have their css structured in their MVC components.
Telerik
Maybe I formulated my question in wrong way, but I was hoping to be directed to some existing .NET APIs to define/generate CSS. Looks like there's nothing like that. And according to the discussion in parallel question, it may not be as useful as I thought.
精彩评论