css新增了一些背景屬性,如下:
background-clip
background-origin
background-size
background-clip設定背景覆蓋範圍,它的屬性值有以下3種
以下是其顯示區域的具體劃分可以參考css盒模型。
>
>
charset
="utf-8"
>
>
background-cliptitle
>
>
divstyle
>
head
>
>
>
div>
style
="background-clip
: border-box;
">
正文div
>
style
="background-clip
: padding-box;
">
正文div
>
style
="background-clip
: content-box;
">
正文div
>
body
>
html
>
示例
在遊覽器上,需要改下成-webkit-background-origin才能正常使用,在css3中增加了大量的瀏覽器專用屬性,大體上可以劃分為4種,如下所示。
字首遊覽器
示例說明
-ms-
ie-ms-animation
ie專屬css屬性
-moz-
firefox
-moz-animation-
基於gecko核心專屬屬性
-webkit-
chrome
-webkit-background-origin
基於webkit核心專屬屬性
background-origin屬性值與background-clip相同,表示背景覆蓋的起點,但在使用過程中,由於背景會縱向重複,像純色的背景,是看不出差別的。background-origin屬性值如下。
>
>
charset
="utf-8"
>
>
backg-origititle
>
>
divstyle
>
head
>
>
>
div>
style
="-webkit-background-origin
: border-box;
">
正文div
>
style
="-webkit-background-origin
: padding-box;
">
正文div
>
style
="-webkit-background-origin
: content-box;
">
正文div
>
style
="clear
: both;
" />
style
="background-repeat
: no-repeat;
">
div>
style
="-webkit-background-origin
: border-box;
background-repeat
: no-repeat;
">
正文div
>
style
="-webkit-background-origin
: padding-box;
background-repeat
: no-repeat;
">
正文div
>
style
="-webkit-background-origin
: content-box;
background-repeat
: no-repeat;
">
正文div
>
body
>
html
>
示例
background-size用於設定背景的大小,預設值是auto。可以給定長度、百分比,如果長度/百分比這種具體的數值只給定乙個,表示高度使用auto;還可以使用cover(影象拉伸到最大完全覆蓋區域,可能會有一部分顯示不全)和contain(將影象擴充套件至最大尺寸,以使其寬度和高度完全適應內容區域)。
**如下
>
>
charset
="utf-8"
>
>
background-sizetitle
>
type
="text/css"
>
divstyle
>
head
>
>
>
div>
style
="background-size
: 30px;
">
div>
style
="background-size
: 30px 60px;
">
div>
style
="background-size
: 30%;
">
div>
style
="background-size
: cover;
">
div>
style
="background-size
: contain;
">
div>
body
>
html
>
CSS3背景屬性
background是乙個使用率很高的屬性,也是乙個非常有用的屬性。背景主要包括5個基本屬性 background color 背景顏色 background image 背景 background repeat 背景展示方式 background attachment 背景是固定還是滾動 back...
CSS3 背景屬性
lang en charset utf 8 背景顏色title type text css divstyle head 背景顏色div body html lang en charset utf 8 背景title type text css divstyle head 背景div body htm...
css3 背景相關的新增屬性
先上 htmllang en head metacharset utf 8 title css3title style div div1 div2 div3 style head body divclass div1 1div divclass div2 2div divclass div3 3di...