background

英[?b?kgra?nd]? ?美[?b?k?ɡra?nd]??

n.(畫等的)背景;底色;背景資料;配樂

複數(shù): backgrounds

position

英[p??z??n]? ?美[p??z???n]??

n.位置,方位;地位,職位;態(tài)度;狀態(tài)

vt.安置;把…放在適當位置;給…定位;駐軍

第三人稱單數(shù): positions 複數(shù): positions 現(xiàn)在分詞: positioning 過去式: positioned 過去分詞: positioned

css background-position屬性 語法

background-position屬性怎麼用?

background-position屬性可以設定背景影像的起始位置。語法為:background-position: x y,其中x表示水平位置,y表示垂直位置;x和y有多種賦值方式,例:top left,3% 2%,xpos ypos。

作用:設定背景影像的起始位置。

說明:這個屬性設定背景原始影像(由?background-image?定義)的位置,背景影像如果要重複,將從這一點開始。

註解:您需要把 background-attachment 屬性設為 "fixed",才能保證該屬性在 Firefox 和 Opera 中正常運作。

可以設定的值:

x% y%xpos ypos#

css background-position屬性 範例

<html>
<head>
<style type="text/css">
body
{ 
  background-image:url('http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg');
  background-repeat:no-repeat;
  background-attachment:fixed;
  background-position:center;
}
</style>
</head>

<body>
<body>
<p><b>提示:</b>您需要把 background-attachment 屬性設置為 "fixed",才能保證該屬性在 Firefox 和 Opera 中正常工作。</p>
</body>
</body>
</html>

執(zhí)行實例 ?

點擊 "執(zhí)行實例" 按鈕查看線上實例

<fieldset id="nf0hd"><abbr id="nf0hd"><legend id="nf0hd"></legend></abbr></fieldset>

    #值描述

    top left

    top center

    top right

    #center left

    ##center center

    center right

    bottom left

    bottom center

    bottom right

    #如果您只規(guī)定了一個關鍵字,那麼第二個值將是" center"。

    預設值:0% 0%。

    第一個值是水平位置,第二個值是垂直位置。?

    左上角是 0% 0%。右下角是 100% 100%。

    如果您只規(guī)定了一個值,另一個值將是 50%。


    第一個值是水平位置,第二個值是垂直位置。

    左上角是 0 0。單位是像素 (0px 0px) 或任何其他的 CSS 單位。

    如果您只規(guī)定了一個值,另一個值將是50%。

    您可以混合使用 % 和 position 值。