背景画像のスクロール時に於ける固着法。
名前 | background-attachment
|
---|---|
値 | <attachment># |
初期値 | scroll |
対象 | 全ての要素 |
継承 | されない |
百分率 | 受容しない |
算出値 | リスト:指定されたキーワードたちからなる |
アニメーション型 | 離散的 |
プロパティの値は、<attachment> キーワードからなる、カンマ区切りの層値リストとして与えられる:
fixed
表示域は各ビューにつき 1 個に限られることに注意。要素がスクロール用の仕組み( overflow プロパティ [CSS2] を見よ)を備えていたとしても、fixed による背景は、要素と伴に移動することはない。
<DIV style="border:1px solid red; width:100px; height:100px; background-image:url(Com/BG1.jpg); background-attachment:fixed; "> </DIV>
<DIV style="border:1px solid red; width:100px; height:100px; background-image:url(Com/BG1.jpg); background-attachment:fixed; overflow:scroll; ">aaaaaaaaaaaaaaaaaaaaa </DIV>
local
<DIV style="border:1px solid red; width:100px; height:100px; background-image:url(Com/BG1.jpg); background-attachment:local; "> </DIV>
<DIV style="border:1px solid red; width:100px; height:100px; background-image:url(Com/BG1.jpg); background-attachment:local; overflow:scroll; ">aaaaaaaaaaaaaaaaaaaaa </DIV>
scroll
<DIV style="border:1px solid red; width:100px; height:100px; background-image:url(Com/BG1.jpg); background-attachment:scroll; "> </DIV>
<DIV style="border:1px solid red; width:100px; height:100px; background-image:url(Com/BG1.jpg); background-attachment:scroll; overflow:scroll; ">aaaaaaaaaaaaaaaaaaaaa </DIV>
画像が表示域(またはページボックス)に固定されたとしても、それが可視になる部分は要素の背景塗り区画に限られる。他の場合は切り取られない(そのような場合のふるまいは、特別な要素の背景に)。したがって、画像は、敷き詰められるのでない限り、不可視になり得る。
下の例は、要素がスクロールされても表示域に“貼り付く”ような、縦に無限に連なる帯を作成する:
body{ background: red url("pendant.gif"); background-repeat: repeat-y; background-attachment: fixed; }
表示内容: |
表示内容: |