寫CSS檔案的流程和CSS代碼順序

來源:互聯網
上載者:User

文章簡介:css製作流程及標準.

css製作流程及標準

(一)製作流程:

1,建立檔案(檔案管理及命名)
2,與html文檔建立關係

注意點:
    1) 不建議使用:內聯樣式和內嵌樣式
          原因:結構(html)和表現(css樣式)沒有分離
    2) 區別:外鏈樣式與匯入樣式(http://zhidao.baidu.com/question/198616109.html)
    3) 網站常用:外鏈樣式

3,製作頁面樣式

注意點:
  • 同html架構一致從上到下
  • 從整體到局部
  • 共用樣式到個別樣式
4,添加註釋

注釋範圍:
    1)每個文檔對應一個文檔注釋(方便後期維護和管理)
          主要注釋說明:文檔建立人,時間,內容等
    2) 屬性注釋說明:css hack,特殊屬性等
    3) 功能注釋說明:預設樣式,按鈕,彈出框等

5,完成檢查

*********************************************************************

(二)製作標準:(有利於開發和後期管理)
這個標準是我們公司的。各個公司有所不同,僅供大家參考~~

縮排及換行:

說明:
縮排:設定tab鍵定位字元(同html的一樣)——點擊tab產生2個空格
換行:
選取器換行:相同樣式2個以上選取器,每個選取器一行
屬性換行:
1)只有一個屬性時,選取器與屬性在同行
2)2個以上屬性,每個屬性佔一行

簡寫
1)顏色:16進位顏色值:#RRGGBB——R,G,B都成對相同時,縮寫成:#RGB
  1. color:#336699;
  2. 簡寫:color:#369;
2)單位:數值為0時,單位可以省略
  1. margin:0px;
  2. 簡寫:margin:0;
3)字型

4)背景
  1. background-color:red;
  2. background-image:url();
  3. background-repeat:no-repeat;
  4. baclgrpimd-position:top right;
  5. background-attachment:fixed;
  6. (每個屬性都可省略)簡寫:background:background-color background-image background-repeat background-position background-attachment;


5)內外邊距(margin與padding簡寫方式相同)

6)邊框
  1. border-width:1px;
  2. border-style:solid;
  3. border-color:red;
  4. 簡寫:border:border-width border-style border-color;
  5.           border:1px solid red;
  6. 單邊簡寫:border-top:1px solid red;
  7.                  border-right:1px solid red;
  8.                  border-bottom:1px solid red;
  9.                  border-left:1px solid red;
  10. (不推薦)單屬性簡寫:(順序:上右下左)
  11. border-width:border-top-width border-right-width border-bottom-width border-left-width;
  12. border-style:border-top-style border-right-style border-bottom-style border-left-style;
  13. border-color:border-top-color border-right-color border-bottom-color border-left-color;

css代碼順序

css文檔的順序
  • 共用的代碼樣式放在文檔最前面
  • css結構的順序依照html的結構

css選取器中的屬性順序 :顯示內容->自身屬性->文字屬性

  • 顯示內容:display, list-style, position, float, clear
  • 自身屬性:width, height, margin, padding,border,background
  • 文字屬性:color, font, text-decoration, text-align,vertical-align, white-space, content

原    因:這個順序是項目開發的代碼標準,符合瀏覽器的
渲染順序,最終達到提高執行效率目的    

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.