background: (1)url(image1.png) right bottom, (2)url(image2.png) center, (3)url(image3.png) (4)rgba( 0,0,0,0.35)css
background-position
and background-repeat
. By default they are positioned top left and get repeated at the x- and y-axis.第一張背景圖是最靠近可視層的。每個背景圖都有通用的背景屬性,最重要的是background-position和bckground-repeat。默認是定位在左上角,並且x與y軸重複。Sets the visible range of the background including background images.設置背景圖片的有效範圍css3
(1)border-box , (2)padding-box,(3)content-boxapp
border-box
, default value). To change this behaviour it’s possible padding-box
and content-box
(Firefox 3.6 uses border
and padding
instead,content
is not supported).元素默認的背景繪製在邊框之下,也就是邊框會覆蓋背景層(默認值border-box)。能夠使用paddng-box和content-box來改變這種行爲。border-box
) when no border is set.若是在元素設置了邊框,超出位置會被截取。即不會繪製到border之下。與不設置border的border-box同樣效果。padding-box
when no padding is set, same as padding-box
and border-box
when no padding and no border are set.若是背景設置了padding,除了內容外都截取。與沒有padding的padding-box同樣,與沒有設置padding和border的padding-box,border-box同樣。(1)padding-box , (2)border-box,(3)content-boxide
padding-box
, default value). In the presence of a border they start directly within it. Can also be content-box
or border-box
(Firefox 3.6 uses padding
,content
and border
).當設置背景圖片時,它是從元素的邊界開始(默認是padding-box)。若是存在邊框,則在邊框內開始。還能夠設置content-box和border-box。padding-box
when no border is set.若是設置了邊框,並且設置border-box,邊框就會覆蓋在背景圖上。若是沒有設置邊框則與padding-box同樣。padding-box
when no padding is set, same as padding-box
and border-box
when no padding and no border are set.設置了content-box,若是設置了padding,背景圖則應用於padding內。和沒有設置padding的padding-box同樣,和沒有設置border與padding的botder-box、padding-box同樣。background-size:(1)50% 100%, (2)33% 33%, auto, 100pxthis
50%
of the width of the element (not of the original image size). 第一個值50%是指背景圖爲元素寬度的50%(並非原始圖的尺寸)Can also be set in absolute (px
) or relative (em
) units, can be auto
(original size, default),cover
or contain
. 也能夠是px或者em,也能夠是auto,cover和contain關鍵字。In combination with multiple background images the different values are separated by commas.多個背景圖時用逗號隔開。(x y 當缺省狀態則爲auto,例如最後一個則是100px auto)background-size: coverurl
background-size: containspa
原文:http://www.css3files.com/background/code