スタイルbackgroundRepeatプロパティ
例
背景画像を繰り返しなしに設定します。
document.body.style.backgroundRepeat = "repeat-y";
以下の「自分で試してみてください」の例をもっと見てください。
定義と使用法
backgroundRepeatプロパティは、background-imageを繰り返す(並べて表示する)方法を設定または返します。
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
Property | |||||
---|---|---|---|---|---|
backgroundRepeat | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
構文
backgroundRepeatプロパティを返します。
object.style.backgroundRepeat
backgroundRepeatプロパティを設定します。
object.style.backgroundRepeat = "repeat|repeat-x|repeat-y|no-repeat|initial|inherit"
プロパティ値
Value | Description |
---|---|
repeat | The background image is repeated both vertically and horizontally. This is default |
repeat-x | The background image is only repeated horizontally |
repeat-y | The background image is only repeated vertically |
no-repeat | The background-image is not repeated |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
技術的な詳細
デフォルト値: | 繰り返す |
---|---|
戻り値: | 背景画像がどのように繰り返されるかを表す文字列 |
CSSバージョン | CSS1 |
その他の例
例
指定されたDIV要素のbackgroundRepeatプロパティを変更します。
document.getElementById("myDIV").style.backgroundRepeat = "repeat-x";
例
背景画像を水平または垂直に繰り返すように設定します。
function repeatVer()
{
document.body.style.backgroundRepeat = "repeat-y";
}
function repeatHor() {
document.body.style.backgroundRepeat = "repeat-x";
}
例
ドキュメントのbackground-repeat値を返します。
alert(document.body.style.backgroundRepeat);
関連ページ
CSSチュートリアル:CSSの背景
CSSリファレンス:background-positionプロパティ
CSSリファレンス:background-repeatプロパティ
HTML DOMリファレンス:背景プロパティ