CSS書寫順序
1、DOM 節點屬性(display及其衍生屬性:display:flex; justify-content: center等)
2、位置關係(position、left、top等)
3、content 外屬性(margin、border、padding)
4、content 屬性(max-width、width、height)
5、行內元素屬性( text-align、color、background等)
6、元素展示屬性(cursor、opacity、border- radius)
例:
display:flex;
justify-content:center;
align-items:center;
position:absolute;
left:0;
top:0;
right:0;
bottom:0;
margin:0 auto;
border:1px solid #eee;
padding:10px;
width:100px;
height:50px;
text-align:center;
color:#fff;
background-color:#000;
cursor:point;
opacity:.5;
border-radius:50%;
overflow:scroll;
class 命名規則
1、class命名以 ‘-’ 連接, 例: c-submit-popup
2、頁面類型的父節點(寫進 router 爲準),使用 p-xxx
3、組件類型的父節點,使用 c-xxx,例:c-submit-btn
4、避免單獨使用 header、footer 等,佈局類型的使用 l-xxx,例: l-top-wrapper
嵌套規則
1、單 vue 頁內 style 應全部包裹在父節點樣式內
2、DOM 嵌套等級不超過三級可使用 c-xx 與 c-xx-xxx 的類名,並在 style 內可使用 &-xxx
3、DOM 嵌套等級超過三級應降低 style 嵌套,具體方法待補充
媒體查詢
儘量將媒體查詢的規則靠近與他們相關的規則,不要將他們一起放到一個獨立的樣式文件中,或者丟在文檔的最底部,這樣做只會讓大家以後更容易忘記他們。