1.模块分割,用如下的标注来提示你的css代码作用;
/* -------------*/ /* ---------->>> GLOBAL <<<-----------*/ /* ----------*/
A sample format I try to stick to is this:
Global Styles – (body, paragraphs, lists, etc)
Header
Page Structure
Headings
Text Styles
Navigation
Forms
Comments
Extras
2.代码的统一管理
例如:
1).标题
h2 { }
#snapshot_box h2 {
padding: 0 0 6px 0; }
#main_box h2 {
color: #e2e2e2; }
.sidetagselection h2 {
color: #fff;
font: bold 14px/14px “Verdana”, sans-serif; }
you’ll be able to style each one independently and not worry about child classes inheriting attributes from the parent class.
3.使用简写
例如:margin: 0px 1px 0 0;
4.头部样式的使用的重要性;important;
If you know that all of the h2’s will not have a margin or padding, define that on the top level and let its effect cascade as it is supposed to.