🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
理想上,**任何** CSS 规则集之前都应该使用 C 风格注释来解释 CSS 块的核心。这个注释也要记录对规则集特定部分编号的解释。比如: ~~~ /** * Helper class to truncate and add ellipsis to a string too long for it to fit * on a single line. * 1\. Prevent content from wrapping, forcing it on a single line. * 2\. Add ellipsis at the end of the line. */ .ellipsis { white-space: nowrap; /* 1 */ text-overflow: ellipsis; /* 2 */ overflow: hidden; } ~~~ 基本上,任何不能明显看出意义的地方都应该注释,但不要随处注释。记住不要**注释太多**,掌握尺度让每一处注释都有意义。 当注释 Sass 的一个特定部分时,应该使用 Sass 单行注释而不是 C 风格的注释块。这么做将不会输出注释,即使是在开发时的扩展模式。 ~~~ // Add current module to the list of imported modules. // `!global` flag is required so it actually updates the global variable. $imported-modules: append($imported-modules, $module) !global; ~~~ ## 扩展阅读 * [CSS Guidelines’ Commenting section](http://cssguidelin.es/#commenting)