CSS 顏色
CSS 的顏色可以通過以下方法指定:
十六進制顏色
p {
background-color: #ff0000;
}
RGB顏色
p {
background-color: rgb(255,0,0);
}
RGBA顏色
p {
background-color: rgb(255,0,0,0.5);
}
英文單詞
p {
background-color: red;
}
背景屬性
#item {
background-image: url("./cs.png");
}
屬性 | 描述 |
---|---|
background | 簡寫屬性,作用是將背景屬性設置在一個聲明中 |
background-attachment | 背景圖像是否固定或者隨着頁面的其餘部分滾動 |
background-color | 設置元素的背景顏色 |
background-image | 把圖像設置爲背景 |
background-position | 設置背景圖像的起始位置 |
background-size | 設置背景圖像大小 |
background-repeat | 設置背景圖像是否及如何重複 |
字體屬性
/* 按所列的順序查找這些字體,遇到可用的字體則使用 */
h1 {
font-family: "微軟雅黑","宋體";
}
屬性 | 描述 |
---|---|
font | 簡寫屬性,作用是把所有針對字體的屬性設置在一個聲明中 |
font-family | 設置字體系列 |
font-size | 設置字體的尺寸 |
font-style | 設置字體風格 |
font-weight | 設置字體的粗細 |
文本屬性
p {
color:red;
text-indent: 15px;
}
屬性 | 描述 |
---|---|
color | 設置文本顏色 |
direction | 設置文本方向 |
text-align | 對齊元素中的文本 |
text-indent | 縮進元素中文本的首行 |
text-transform | 控制元素中的字母大小寫 |
text-decoration | 向文本添加修飾 |
text-shadow | 向文本添加陰影 |
text-wrap | 規定文本的換行規則 |
line-height | 設置行高 |
white-space | 設置元素中空白的處理方式 |
word-spacing | 設置字間距 |
letter-spacing | 設置字符間距 |
邊框屬性
div {
border: 1px solid red;
}
屬性 | 描述 |
---|---|
border | 簡寫屬性,用於把針對四個邊的屬性設置在一個聲明 |
border-style | 設置元素邊框樣式 |
border-width | 設置元素邊框寬度 |
border-color | 設置元素邊框顏色 |
border-bottom | 設置元素下邊框 |
border-left | 設置元素左邊框 |
border-right | 設置元素右邊框 |
border-top | 設置元素上邊框 |
border-radius | 設置邊框圓角 |
box-shadow | 設置邊框陰影 |