CSS最佳化壓縮

來源:互聯網
上載者:User

標籤:

顧名思義縮寫有簡寫意思,那就總結一下CSS縮寫知識點。
為什麼要讓CSS屬性縮寫?
1、簡化代碼。一些CSS屬性簡寫可以減少CSS代碼從而減少CSS檔案的佔用位元組。加快網頁下載速度和網頁載入速度。
2、最佳化CSS目的。其中CSS最佳化之一即是簡化代碼縮寫CSS屬性代碼。
一、CSS樣式屬性單詞代碼簡寫最佳化
(1)CSS文本:

font-size:12px;font-weight:bold;font-family:Arial, Helvetica, sans-serif;line-height:22px;即可簡寫縮寫成:font:12px/22px bold Arial,Helvetica, sans-serif; 

(2)CSS背景:

background-color:#F00;background-image:url(圖片地址);background-position:bottom;background-repeat:no-repeat;即可將背景CSS屬性縮寫為:background:#F00 url(圖片地址) no-repeat bottom;

(3)CSS內補距(CSS padding):

padding-top:5px;paddding-right:20px;padding-bottom:10px;padding-left:15px;即可縮寫為:padding:5px 20px 10px 15px;或者padding-top:5px;padding-bottom:5px;padding-left:10px;padding-right:10px;縮寫為:padding:5px 10px;

(4)CSS外邊距(CSS margin):

margin-top:5px;         margin-right:20px;margin-bottom:10px;margin-left:15px;即可縮寫為margin:5px 20px 10px 15px;或:margin-top:5px;margin-bottom:5px;margin-left:10px;margin-right:10px;縮寫為:margin:5px 10px;

(5)、CSS 邊框:                          

border-top:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000;border-left:1px solid #000;即可縮寫為:border:1px solid #000;

二、標點符號最佳化:
總結:總結常用的CSS 縮寫,希望在以後製作實踐中多多使用和多多總結。

CSS最佳化壓縮

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.