CSS - background-repeat

トップ > CSSリファレンス > background-repeat

概要

属性名 background-repeat
<repeat>[, <repeat>]*
値の詳細 <repeat> = repeat-x | repeat-y | [ repeat | no-repeat | space | round ]{1,2}
初期値repeat
適用可能要素すべての要素
継承継承しない
メディアvisual
アニメーション不可

サポート (説明)

CSSIE/EdgeFirefoxChromeOperaSafari
基本CSS14.01.01.03.51.0
複数背景CSS39.03.61.010.51.3
roundCSS39.0未対応31以前10.5未対応
spaceCSS39.0未対応32以降46以前10.5未対応

説明

背景画像の繰り返し方法を指定します。

説明
repeat-x横方向のみリピートします。
repeat-y縦方向のみリピートします。
repeatリピートします。
no-repeatリピートしません。
spaceリピートします。画像サイズが表示領域の整数倍でない場合は、画像間にスペースを入れて調整します。
roundリピートします。画像サイズが表示領域の整数倍でない場合は、画像を拡大・縮小して調整します。

repeat, no-repeat, space, round をひとつのみ記述した場合は、横方向、縦方向双方に適用されます。ふたつ記述した場合は、横方向、縦方向の順に適用されます。

CSS
background-repeat: no-repeat;         /* 横:no-repeat、縦:no-repeat */
background-repeat: repeat no-repeat;  /* 横:repeat、縦:no-repeat */

使用例

CSS
.test-repeat {
  background-repeat: repeat;
  background-image: url(./image/back.gif);
  width: 85px;
  height: 85px;
  border: 1px solid gray;
}
.test-repeat-x {
  background-repeat: repeat-x;
  background-image: url(./image/back.gif);
  width: 85px;
  height: 85px;
  border: 1px solid gray;
}
.test-repeat-y {
  background-repeat: repeat-y;
  background-image: url(./image/back.gif);
  width: 85px;
  height: 85px;
  border: 1px solid gray;
}
.test-no-repeat {
  background-repeat: no-repeat;
  background-image: url(./image/back.gif);
  width: 85px;
  height: 85px;
  border: 1px solid gray;
}
.test-space {
  background-repeat: space;
  background-image: url(./image/back.gif);
  width: 85px;
  height: 85px;
  border: 1px solid gray;
}
.test-round {
  background-repeat: round;
  background-image: url(./image/back.gif);
  width: 85px;
  height: 85px;
  border: 1px solid gray;
}
HTML
<h5>repeat</h5>
<div class="test-repeat"></div>
<h5>repeat-x</h5>
<div class="test-repeat-x"></div>
<h5>repeat-y</h5>
<div class="test-repeat-y"></div>
<h5>no-repeat</h5>
<div class="test-no-repeat"></div>
<h5>space</h5>
<div class="test-space"></div>
<h5>round</h5>
<div class="test-round"></div>
表示
repeat
repeat-x
repeat-y
no-repeat
space
round

関連項目

background, background-color, background-image, background-repeat, background-attachment, background-position, background-clip, background-origin, background-size

リンク


Copyright (C) 1997-2015 杜甫々
初版:1997年7月27日、最終更新:2015年11月29日
http://www.tohoho-web.com/css/prop/background-repeat.htm