日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網營銷解決方案
由布局學習CSS:從CSS sprites重視background

關于CSS sprite技術的詳解,小弟在這里就不贅述了,因為偉大的英特網上有一篇偉大的技術文檔介紹。請移步http://css-tricks.com/css-sprites/

在CSS sprite中最重要的就是關于background這個屬性的理解,所以本文比較詳細的介紹了background這個屬性,如有錯誤,勞請指教。

background的集合有: 'background-color', 'background-image', 'background-repeat', 'background-attachment','background-position', 和'background'。

在介紹background特性之前首先要明確background的作用范圍,background是在padding box之內有效,所以背景色和背景圖片都在此范圍內。

 
 
 
 
  1.  
  2.  
  3.      
  4.          
  5.          
  6.          
  7.       
  8.      
  9.      
  10.              
  11.                 Test background scope  
  12.             
 
  •              
  •                 Test background scope  
  •             
  •  
  •         
  •  
  •      
  •       
  •  
  • background的核心屬性background-position

    'background-position'

    Value:  [ [  |  | left | center | right ] [  |  | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ] | inherit
    Initial:  0% 0%
    Applies to:  all elements
    Inherited:  no
    Percentages:  refer to the size of the box itself
    Media:  visual
    Computed value:  for  the absolute value, otherwise a percentage

    (1)百分數(shù)

    將background-position設置為百分數(shù),可以將其歸結為跟蹤原則。background-position:x% y%,是指以圖片左上角為原點的A(圖片長度的x%,圖片高度的y%)點和以paddingbox的左上角為原點的B(paddingbox長度的 x%,paddingbox高度的y%)點,相合重合。

    (2)數(shù)值將

    background-position設置為數(shù)值,可以將其歸結為掛靠原則。background-position:Xpx Ypx,是指圖片的左上角掛靠的以paddingbox的左上角為原點的倒直角坐標系,B(Xpx, Ypx)點。例如:background-position:50px 50px,是指將圖片的左上角掛靠在以paddingbox的左上角為原點的倒直角坐標系,B(50px, 50px)點.background-position:-50px -50px,是指將圖片的左上角掛靠在以paddingbox的左上角為原點的倒直角坐標系,B(-50px, -50px)點。

    綜合實例:

     
     
     
     
    1.  
    2.  
    3.      
    4.          
    5.          
    6.         #div3{  
    7.         background-image:url(test.gif);  
    8.         padding:50px;  
    9.         width:100px;  
    10.         height:100px;  
    11.         border:2px solid green;  
    12.         margin:50px;  
    13.         background-position:20% 20%;  
    14.         }  
    15.         #div4{  
    16.         background-image:url(test.gif);  
    17.         padding:50px;  
    18.         width:150px;  
    19.         height:150px;  
    20.         border:2px solid green;  
    21.         margin:50px;  
    22.         background-position:50px 50px;  
    23.         background-repeat:no-repeat;  
    24.         }  
    25.         #div5{  
    26.         background-image:url(test.gif);  
    27.         padding:50px;  
    28.         width:150px;  
    29.         height:150px;  
    30.         border:2px solid green;  
    31.         margin:50px;  
    32.         background-position:-50px -50px;  
    33.         background-repeat:no-repeat;  
    34.         }  
    35.          
    36.           
    37.       
    38.      
    39.      
    40.              
    41.                 Test background scope  
    42.             
     
  •              
  •                 Test background scope  
  •             
  •  
  •              
  •                 Test background scope  
  •             
  •  
  •              
  •                 Test background scope  
  •             
  •  
  •              
  •                 Test background scope  
  •             
  •  
  •         
  •  
  •      
  •       
  •  

  • 標題名稱:由布局學習CSS:從CSS sprites重視background
    標題網址:http://www.5511xx.com/article/coiosji.html