CSS background背景相關屬性

2021-10-03 10:47:13 字數 1653 閱讀 3640

1、background背景相關

background-color:背景顏色;

顏色單詞 red blue green....

十六進製制值 # 0-9 a-f

三原色值 rgb(0,0,0) 0-255

example:

background-color

:pink;

background-color

:#ccc;

background-color

:rgb

(255,255,255)

;

background-image:url("路徑");

1:預設情況是平鋪的

2:與img標籤的區別:

img是標籤,是結構,佔據頁面位置

掛在牆上的一幅畫,可以蓋住背景圖

backgorund-image:;是css樣式,不佔據位置

畫在牆上的一幅畫,被img蓋住

example:

background-image

:url("img/list.png")

;

background-repeat:是否重複;

repeat 重鋪(預設值)

no-repeat 不重鋪

repeat-x 水平重鋪

repeat-y 垂直重鋪

example

background-repeat

:repeat;(預設值)(見下圖左)

background-repeat

:no-repeat;(見下圖右)

background-position:背景定位;

1:關鍵字寫法

水平值 left center right

垂直值 top center bottom

2:具體畫素位置

example

:1:關鍵字寫法

background-position

:left top;

/*預設值*/

background-position

:left center;(左中)(見下圖)

2:具體畫素寫法

background-position

:-113px -208px;

/*改變背景圖位置*/

background-attachment:scroll;/*背景關聯 滾動*/

background-attachment:fixed;/*背景關聯 固定*/

css background 背景知識詳解

我們知道元素有前景色color,與之對應的還有背景色,通過background我們可以為元素新增實色 background color 和任意多個背景 background image css 背景常見屬性 background color 屬性設定元素的背景顏色。它會會填充元素的內容 內邊距和邊框...

CSS background系列屬性

關於顏色 能夠用英語單詞來表述的顏色都是簡單的顏色 用rgb方法來表示 光學顯示器每個畫素都是由三原色的發光原件組成的,靠明亮度不同調成不同顏色。用逗號隔開,r,g,b的值,每個值的取值範圍0 255,一共256個值。如果此項值是255,就說明是純色。紅色 background color rgb ...

css background屬性詳細解析

css可以控制html中各元素的背景顯示,包括背景顏色 背景 背景重複 背景定位和背景關聯5項。在css中,可以通過background屬性對這5項統一控制,也可通過這5項對應的屬性分別控制。下面我們先了解一下css中的這5個屬性。css可以為所有元素設定背景色,從body 一直到em 和a 等內聯...