HTML常用的css屬性(及其簡寫)
阿新 • • 發佈:2021-01-07
這篇文章主要介紹幾個常用css屬性和簡寫
本文目錄:
1.背景屬性
2.邊框屬性
3.字型屬性
4.外邊距
5.填充
6.顏色
1.background【背景屬性】
background-color /*背景色*/
background-image /*背景圖片*/
background-repeat /*背景圖平鋪方式*/
簡寫:background: 背景色 背景圖片 平鋪方式t;
例如:background: gray url(xxx/xx.png) no-repeat;
2.border【邊框屬性】
border-width /*邊框寬度*/ border-style /*邊框樣式*/ border-color /*邊框顏色*/
簡寫:border:邊框寬度 邊框樣式 邊框顏色
例如:border:1px solid #D3f402;
可以省略顏色,但寬度和樣式不能省略。
例如:border: 3px dashed; /*顏色預設為黑色*/
3.font【字型屬性】
font-style: italic; /*斜體*/
font-weight: bold; /*加粗*/
font-family: arial,sans-serif; /*字型種類*/
font-size: 20px; /*字號大小*/
line-height: 35px; /*行高*/
簡寫:font: 斜體字 加粗 字號大小/行高 預設字型,備用字型, 備用字型;
例如:font: italic bold 20px/35px arial,sans-serif, "微軟雅黑";
可以省略,但順序不可顛倒,注意符號。
4.margin【外邊距】
margin-top/*上邊距*/
margin-right/*右邊距*/
margin-bottom/*下邊距*/
margin-left/*左邊距*/
簡寫:
※這裡引數值可以有1~4個
(1)一個引數
margin: 上右下左;
例如:margin: 10px;
(上右下左邊距都為10px)
(2)兩個引數:
margin: 上右 下左;
例如:margin: 5px 10px;
(上右邊距5px,下左邊距10px)
(3)三個引數:
margin: 上 左右下; 例如:margin: 5px 10px 15px; (上邊距5px,左右邊距10px,下邊距15px)
(4)四個引數:
margin: 上 右 下 左;
例如:margin: 10px 15px 10px 15px;
(上邊距10px,右邊距15px,下邊距10px,左邊距15px)
5.padding【填充】
padding-top/*上填充*/
padding-right/*右填充*/
padding-bottom/*下填充*/
padding-left/*左填充*/
簡寫:[和"4.margin【外邊距】"相同]
6.【顏色】
(1)名稱->color: DarkGoldenRod;
(2)RGB值->color: rgb( 184,134,11 );
(3)[rgb值的]十六進位制->color:#B8860B