Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS 代码风格的几点建议 #20

Open
yisibl opened this issue May 6, 2016 · 0 comments
Open

CSS 代码风格的几点建议 #20

yisibl opened this issue May 6, 2016 · 0 comments

Comments

@yisibl
Copy link

yisibl commented May 6, 2016

每条样式声明后面都加上那个分号。
理由:复制起来方便。

改成「理由:可维护性更好,在最后一行添加新的声明时如果忘记了分号会导致语法错误。」

避免使用 ID 选择器。

如果可以确定是全站唯一的节点,可以使用 ID 选择器,比如典型的 header,footer。通常表单元素也可以使用 ID 选择器。

0 值的单位建议省略,但不强制。

规范中除了 <length>外的取值都不可以省略 0 值后面的单位,WebKit/Blink 可以省略,但这是 Bug。所以书写规范中,不建议推荐省略,应该交给 CSS 压缩工具或者处理器来处理。https://twitter.com/tabatkins/status/676297504237879296

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant