一、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等)
二、css属性缩写和简写
1.在css的属性中,有些是可以缩写的,这样不仅代码少了,而且速度也可以提高。比如margin、padding、background等属性都可以进行缩写。(如:margin:10px;)
2.有些值是0,这时候我们可以省略后面的px单位,有时候是零点几,这时候我们可以省略这个零。再简写class名称的时候一定要让其他人看得明白。(如:opacity: .6;)
3.有很多新手经常用id选择器,其实这是不好的习惯,id选择器一定要慎重使用,最好用class选择器,当感觉这个模块唯一的时候才选择用id选择器,一般id都留给js使用。
三、css文件名命名规则