firefox推薦與個人理解的css書寫順序

來源:互聯網
上載者:User

最近的工作中,遇到不少問題,其中一個問題我覺得是最重要的,那就是css的書寫順序,他可以體現一個前端工作者的思續。如果您看到本文,請不要再想到哪個屬性就寫哪個屬性。

先來看一下firefox推薦的書寫順序
* mozilla.org Base Styles
* maintained by fantasai
* (classes defined in the Markup Guide -http://mozilla.org/contribute/writing/markup)
*/
/* Suggested order:
//顯示內容
* display
* list-style
* position
* float
* clear
//自身屬性
* width
* height
* margin
* padding
* border
* background
//文字屬性
* color
* font
* text-decoration
* text-align
* vertical-align
* white-space
* other text
* content
*
*/
從上面推薦的順序可以看出,非常的有條理。上面推薦的順序並沒有把更加詳細的屬性寫進去,比如:top,right,bottom,left等,也許有人會問,這樣些對效能有什麼影響嗎?我非常遺憾的告訴你,我也不知道,但我想,有條理的做事才是正確的(也許你有更好的方法)。

我的理解:
1.顯示內容:display||visibility||list-style(list-style-type、list-style-image、list-style-position)||overflow
2.定位及浮動屬性:position||top||right||bottom||left||float||clear
3.盒模型:width||height||margin||padding||border
4.背景:background(background-image、background-position、background-repeat、background-attachment)
5.文字屬性:font-style||font-variant||font-weight||font-size||font-family||color
6.文字屬性:text-indent||text-align||vertical-align||letter-spacing||word-spacing||text-transform||text-decoration||text-shadow
7.其它

引用某位人的話,”不管你用不用這個順序,反正我是用了”。歡迎大家指正

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.