What are the best practices for writing maintainable CSS?

后端 未结 9 1922
礼貌的吻别
礼貌的吻别 2021-02-06 04:25

I am just starting to explore this area and wonder what are the best practices when it comes to production of clean, well-structured and maintainable CSSes.

There seems

9条回答
  •  借酒劲吻你
    2021-02-06 05:15

    As with most "best practices" there is no right answer here. I think that others' suggestions and styles are generally good though.

    While I love CSS I think CSS has failed us all in this regard. The language is stale and could use a lot of improvement in ways to help us organize large and complex CSS files. One good effort in this direction is http://LESScss.org . They have extended CSS with variables, mixins, nested rules and even operations that allow css to be a lot more DRY and manageable.

    It isn't /true/ CSS as you have to preprocess the LESS to turn it into CSS that a browser would understand but that is a quick and easy step that might be worth it to you if your CSS is growing unwieldy.

    So if you're finding CSS unwieldy it might be worth giving a try.

提交回复
热议问题