一、CSS书写顺序
1.位置属性(position, top, right, z-index, display, float等)
2.大小(width, height, padding, margin)
3.文字系列(font, line-height, letter-spacing, color- text-align等)
4.背景(background, border等)
5.其他(animation, transition等)
当一个 rule 包含多个 selector 时,每个选择器声明必须独占一行。
/* good */
.post,
.page,
.comment {
line-height: 1.5;
}
>、+、~ 选择器的两边各保留一个空格。
/* good */
main > nav {
padding: 10px;
}
选择器 与 { 之间必须包含空格。
.selector {
}
属性名 与之后的 : 之间不允许包含空格, : 与 属性值 之间必须包含空格。
margin: 0;
1.位置属性(position, top, right, z-index, display, float等)
2.大小(width, height, padding, margin)
3.文字系列(font, line-height, letter-spacing, color- text-align等)
4.背景(background, border等)
5.其他(animation, transition等)
当一个 rule 包含多个 selector 时,每个选择器声明必须独占一行。
/* good */
.post,
.page,
.comment {
line-height: 1.5;
}
>、+、~ 选择器的两边各保留一个空格。
/* good */
main > nav {
padding: 10px;
}
选择器 与 { 之间必须包含空格。
.selector {
}
属性名 与之后的 : 之间不允许包含空格, : 与 属性值 之间必须包含空格。
margin: 0;