DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> CSS入門知識 >> CSS進階教程 >> CSS教程:背景background屬性應用
CSS教程:背景background屬性應用
編輯:CSS進階教程     

poluoluo文章簡介:背景background:background-image:url("圖片的網址");背景圖background: url(" 圖片的網址 "); 背景.background-color:#色碼;背景色彩.

背景 background 

css  說明 
background-image:url("圖片的網址");  背景圖 
background: url(" 圖片的網址 ");  背景  
background-color:#色碼;  背景色彩  

Exp: 
background-image:url(背景圖案.jpg,gif,bmp); 
background-color:#FFFFFF;  
background-color : transparent;    <--設定背景為透明色 

--------------------------------------------------------------------------------

background-repeat 改變背景圖片的重復並排的設定 

css
 說明 
repeat  背景圖片並排  
repeat-x  背景圖片以X方向 並排  
repeat-y  背景圖片以Y方向 並排  
no-repeat  背景圖片不 以並排的方式處理  

Exp: 
background-image:url("http://www.webjx.com/xx.gif"); 
background-repeat:no-repeat; 
以http://www.webjx.com/xx.gif這張圖片為背景,當圖片大小不夠的時候,不並排重復 

--------------------------------------------------------------------------------

background-attachment是否固定圖片位置 

css
 說明 
scroll  拉動卷軸時,背景圖片會跟著移動(缺省值)  
fixed  拉動卷軸時,背景圖片不會跟著移動  

Exp: 
background-image:url("http://www.webjx.com/xx.gif"); 
background-repeat:no-repeat; 
background-attachment:fixed; 
以http://www.webjx.com/xx.gif背景圖片不重復並列,且不隨卷軸移動 

--------------------------------------------------------------------------------

以長度定位background-position: x y 
使用百分比定位 background-position: x% y% 

css
 說明 
x%  往右移  
y%  往下移  
backgroud-position: 0% 0%; 左邊上方
backgroud-position: 0% 50%; 左邊中間
backgroud-position: 50% 0%; 中間上方
backgroud-position: 50% 50%; 正中間
backgroud-position:100% 0%; 右邊上方
backgroud-position: 0% 100%; 左邊下方
backgroud-position: 100% 50%; 右邊中間
backgroud-position: 50% 100%; 中間下方
backgroud-position: 100% 100%; 右邊下方

以關鍵字定位 
關鍵字  說明  
top  上 ( y = 0 )  
center  中 ( x = 50, y = 50 )  
bottom  下 ( y = 100 )  
left  左 ( x= 0 )  

Exp: 
background-position:center; 
圖片在指定背景中央X=50% Y=50%位置 
background-position: 200px 30px 
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved