Structured way to organize CSS code

北战南征 提交于 2019-12-05 10:03:52

I used to love LESS, but now I'm a big fan of Stylus because I think it makes even cleaner code than LESS/SASS/CSS -- no semicolons, colons, or brackets.

Because Stylus (and LESS and SASS) allow you to define variables and templates and functions, I have the following files, which should be in this order:

  • reset - A Stylus version of Eric Meyer's CSS reset
  • variables - Variables like colors, fonts, etc.
  • templates - Templates like border-radius, transitions, and clearfix
  • Stylings for each page (homepage, app, terms of service, etc)

These are all concatenated and compiled to CSS using a simple build script.

You can see what these look like; I made a GitHub repo for this stuff.

For writing consistent and manageable stylesheets CSS LESS Framework is very beneficial.
LESS provides the following mechanisms: variables, nesting, mixins, operators and functions for writing CSS codes dynamically and can run on the client-side (Internet Explorer 6+, WebKit, Firefox) and server-side, with Node.js or Rhino.

http://lesscss.org/

Regarding Stylus — lack of semicolons, colons, and brackets makes your code less readable IMO, rather than moreso.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!