From dc36f70aa600797fd07c7324f39fdde1a5ae71d9 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sun, 14 Nov 2021 10:11:43 +0900 Subject: CSS Backgrounds に関するプロパティの文書を更新 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 2021/11/12 時点の英語版に同期 --- files/ja/web/css/background-origin/index.md | 141 +++++++++++++++------------- 1 file changed, 76 insertions(+), 65 deletions(-) (limited to 'files/ja/web/css/background-origin') diff --git a/files/ja/web/css/background-origin/index.md b/files/ja/web/css/background-origin/index.md index 34ec2d7dee..74b19a3de6 100644 --- a/files/ja/web/css/background-origin/index.md +++ b/files/ja/web/css/background-origin/index.md @@ -2,29 +2,26 @@ title: background-origin slug: Web/CSS/background-origin tags: - - Background - CSS + - CSS 背景 - CSS プロパティ - - CSS 背景と境界 - - Reference - - background-origin + - リファレンス + - recipe:css-property +browser-compat: css.properties.background-origin translation_of: Web/CSS/background-origin --- -
{{CSSRef}}
+{{CSSRef}} -

CSSbackground-origin プロパティは、背景配置領域を設定します。言い換えれば、 {{cssxref("background-image")}} プロパティで指定された画像の原点の位置を設定します。

+[CSS](/ja/docs/Web/CSS) の **`background-origin`** プロパティは、背景配置領域を境界の開始位置、境界の内部、パディングの内部から設定します。 -
{{EmbedInteractiveExample("pages/css/background-origin.html")}}
+{{EmbedInteractiveExample("pages/css/background-origin.html")}} - +{{cssxref("background-attachment")}} が `fixed` のときは `background-origin` が無視されることに注意してください。 -

{{cssxref("background-attachment")}} が fixed のときは background-origin が無視されることに注意してください。

+## 構文 -
メモ: {{cssxref("background")}} 一括指定プロパティは、該当する値を設定しなかった場合、このプロパティの値を初期値にリセットします。
- -

構文

- -
/* キーワード値 */
+```css
+/* キーワード値 */
 background-origin: border-box;
 background-origin: padding-box;
 background-origin: content-box;
@@ -32,79 +29,93 @@ background-origin: content-box;
 /* グローバル値 */
 background-origin: inherit;
 background-origin: initial;
+background-origin: revert;
 background-origin: unset;
-
+``` + +`background-origin` プロパティは、以下の一覧にあるキーワード値のうちの一つで指定します。 + +### 値 -

background-origin プロパティは、以下の一覧にあるキーワード値のうちの一つで指定します。

+- `border-box` + - : 背景は境界ボックスからの相対位置になります。 +- `padding-box` + - : 背景はパディングボックスからの相対位置になります。 +- `content-box` + - : 背景はコンテンツボックスからの相対位置になります。 -

+## 公式定義 -
-
border-box
-
背景は境界ボックスからの相対位置になります。
-
padding-box
-
背景はパディングボックスからの相対位置になります。
-
content-box
-
背景はコンテンツボックスからの相対位置になります。
-
+{{cssinfo}} -

形式文法

+## 形式文法 {{csssyntax}} -

+## 例 -
.example {
+### 背景画像の原点を設定
+
+```css
+.example {
   border: 10px double;
   padding: 10px;
   background: url('image.jpg');
   background-position: center left;
   background-origin: content-box;
 }
-
+``` -
#example2 {
+```css
+#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'); /* 背景に二つの画像を適用 */
+```css
+div {
+  background-image: url('logo.jpg'), url('mainback.png'); /* 背景に 2 つの画像を適用 */
   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")}}

- -

関連情報

- - +} +``` + +

2 つのグラデーションの使用

+ +この例では、ボックスに太い点線の境界線が付いています。最初のグラデーションでは、 `padding-box` を `background-origin` として使用しているため、背景は境界線の内側に表示されます。2 つ目のグラデーションは、`content-box`を使用しているため、コンテンツの後ろにのみ表示されます。 + +```css +.box { + margin: 10px 0; + color: #fff; + background: linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,0.6) 60%, rgba(252,176,69,1) 100%), + radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(0,0,0,1) 28%); + border: 20px dashed black; + padding: 20px; + width: 400px; + background-origin: padding-box, content-box; + background-repeat: no-repeat; +} +``` + +```html +
Hello!
+``` + +{{EmbedLiveSample('Using_two_gradients', 420, 140)}} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- {{cssxref("background-clip")}} -- cgit v1.2.3-54-g00ecf