CSS中background屬性詳解_CSS教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!
      CSS背景屬性 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.wf0088.com/xx.gif");
      background-repeat:no-repeat;
      以http://www.wf0088.com/xx.gif這張圖片為背景,當圖片大小不夠的時候,不并排重復

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

      background-attachment是否固定圖片位置

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

      Exp:
      background-image:url("http://www.wf0088.com/xx.gif");
      background-repeat:no-repeat;
      background-attachment:fixed;
      以http://www.wf0088.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
        
        

      來源:52CSS//所屬分類:CSS教程/更新時間:2012-06-20
      相關CSS教程