--- title: background-origin slug: Web/CSS/background-origin tags: - Background - CSS - CSS プロパティ - CSS 背景と境界 - Reference - background-origin translation_of: Web/CSS/background-origin ---
CSS の background-origin プロパティは、背景配置領域を設定します。言い換えれば、 {{cssxref("background-image")}} プロパティで指定された画像の原点の位置を設定します。
このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 https://github.com/mdn/interactive-examples をクローンしてプルリクエストを送信してください。
{{cssxref("background-attachment")}} が fixed のときは background-origin が無視されることに注意してください。
/* キーワード値 */ background-origin: border-box; background-origin: padding-box; background-origin: content-box; /* グローバル値 */ background-origin: inherit; background-origin: initial; background-origin: unset;
background-origin プロパティは、以下の一覧にあるキーワード値のうちの一つで指定します。
border-boxpadding-boxcontent-box.example {
border: 10px double;
padding: 10px;
background: url('image.jpg');
background-position: center left;
background-origin: content-box;
}
#example2 {
border: 4px solid black;
padding: 10px;
background: url('image.gif');
background-repeat: no-repeat;
background-origin: border-box;
}
div {
background-image: url('logo.jpg'), url('mainback.png'); /* 背景に二つの画像を適用 */
background-position: top right, 0px 0px;
background-origin: content-box, padding-box;
}
| 仕様書 | 状態 | 備考 |
|---|---|---|
| {{SpecName('CSS3 Backgrounds', '#the-background-origin', 'background-origin')}} | {{Spec2('CSS3 Backgrounds')}} | 初回定義 |
{{cssinfo}}
{{Compat("css.properties.background-origin")}}