css學習筆記之CSS縮寫筆記

來源:互聯網
上載者:User


字型

font:font-style | font-variant | font-weight | font-size | line-height | font-family ;

Margin & Padding
magin: magin-top | margin-right | margin-bottom | margin-left;
P {magin:20px;}
P {magin:20px 10px;}
P {magin:20px 10px 100px;} 上邊距20px,左右10px,下邊距100px


邊框

border:border-width | border-style | color

border-top:border-width | border-style | color
border_right:border-width | border-style | color
border-bottom:border-width | border-style | color
border-left:border-width | border-style | color


border-width: top | right | bottom | left
border-color: top | right | bottom | left
border-style: top | right | bottom | left

支援1-4個參數的縮寫


List 列表縮寫
list-style:list-style-type | list-style-position | list-style-image


Background 縮寫

background: background-color | background-image |background-repeat | background-attachment | background-position

color 縮寫

顏色
16進位的色彩值,如果每兩位的值相同,可以縮寫一半,例如:
#000000可以縮寫為#000;#336699可以縮寫為#369;

盒尺寸

通常有下面四種書寫方法:

•property:value1; 表示所有邊都是一個值value1;
•property:value1 value2; 表示top和bottom的值是value1,right和left的值是value2
•property:value1 value2 value3; 表示top的值是value1,right和left的值是value2,bottom的值是value3
•property:value1 value2 value3 value4; 四個值依次表示top,right,bottom,left

方便的記憶方法是順時針,上右下左。具體應用在margin和padding的

例子如下:

margin:1em 0 2em 0.5em;

CSS 內補距(CSS padding):


padding-top:5px; padding-bottom:10px; padding-left:15px; padding-right:20px;

即可縮寫為

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

CSS 外邊距(CSS margin):

margin-top:5px; margin-bottom:10px; margin-left:15px; margin-right:20px;

即可縮寫為

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

聯繫我們

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