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-attachment/index.md | 155 ++++++++++-------------- 1 file changed, 67 insertions(+), 88 deletions(-) (limited to 'files/ja/web/css/background-attachment') diff --git a/files/ja/web/css/background-attachment/index.md b/files/ja/web/css/background-attachment/index.md index 230923fd03..a4d68539be 100644 --- a/files/ja/web/css/background-attachment/index.md +++ b/files/ja/web/css/background-attachment/index.md @@ -3,23 +3,23 @@ title: background-attachment slug: Web/CSS/background-attachment tags: - CSS - - CSS Background - - CSS Property - - Reference - - 'recipe:css-property' + - CSS 背景 + - CSS プロパティ + - リファレンス + - recipe:css-property +browser-compat: css.properties.background-attachment translation_of: Web/CSS/background-attachment --- -
{{CSSRef}}
+{{CSSRef}} -

background-attachmentCSS のプロパティで、背景画像の位置を{{glossary("Viewport", "ビューポート")}}の中で固定するか、包含ブロックと一緒にスクロールするかを設定します。

+**`background-attachment`** は [CSS](/ja/docs/Web/CSS) のプロパティで、背景画像の位置を{{glossary("Viewport", "ビューポート")}}の中で固定するか、包含ブロックと一緒にスクロールするかを設定します。 -
{{EmbedInteractiveExample("pages/css/background-attachment.html")}}
+{{EmbedInteractiveExample("pages/css/background-attachment.html")}} - +## 構文 -

構文

- -
/* キーワード値 */
+```css
+/* キーワード値 */
 background-attachment: scroll;
 background-attachment: fixed;
 background-attachment: local;
@@ -27,62 +27,65 @@ background-attachment: local;
 /* グローバル値 */
 background-attachment: inherit;
 background-attachment: initial;
+background-attachment: revert;
 background-attachment: unset;
-
+``` -

background-attachment プロパティは、以下に挙げた値のうちの一つで指定します。

+`background-attachment` プロパティは、以下に挙げた値のうちの一つで指定します。 -

+### 値 -
-
fixed
-
背景はビューポートに対する相対位置で固定されます。要素がスクロール機構を持っていたとしても、背景画像は要素とともには動きません。 (これは {{cssxref("background-clip", "background-clip: text", "#text")}} とは両立できません)
-
local
-
背景は要素の内容に対する相対位置で固定されます。要素がスクロール機構を持っていた場合、背景画像は要素の内容とともにスクロールします。背景画像の描画エリアと配置エリアは、それらを囲む境界ではなく、要素のスクロール可能なエリアを基準にします。
-
scroll
-
背景は要素自身に対する相対位置で固定され、内容と共にスクロールしません。 (要素の境界に対して効果的に張り付きます。)
-
+- `fixed` + - : 背景はビューポートに対する相対位置で固定されます。要素がスクロール機構を持っていたとしても、背景画像は要素とともには動きません。 (これは {{cssxref("background-clip", "background-clip: text", "#values")}} とは両立できません) +- `local` + - : 背景は要素の内容に対する相対位置で固定されます。要素がスクロール機構を持っていた場合、背景画像は要素の内容とともにスクロールします。背景画像の描画エリアと配置エリアは、それらを囲む境界ではなく、要素のスクロール可能なエリアを基準にします。 +- `scroll` + - : 背景は要素自身に対する相対位置で固定され、内容と共にスクロールしません。 (要素の境界に対して効果的に張り付きます。) -

公式定義

+## 公式定義 -

{{cssinfo}}

+{{cssinfo}} -

形式文法

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

+## 例 -

単純な例

+

単純な例

-

HTML

+#### HTML -
<p>
+```html
+

There were doors all round the hall, but they were all locked; and when Alice had been all the way down one side and up the other, trying every door, she walked sadly down the middle, wondering how she was ever to get out again. -</p>

+

+``` -

CSS

+#### CSS -
p {
-  background-image: url("https://mdn.mozillademos.org/files/12057/starsolid.gif");
+```css
+p {
+  background-image: url("starsolid.gif");
   background-attachment: fixed;
 }
-
+```

結果

-

{{EmbedLiveSample("Simple_example")}}

+{{EmbedLiveSample("Simple_example")}} -

複数の背景画像

+

複数の背景画像

-

このプロパティは複数の背景画像に対応しており、それぞれの背景画像に異なる <attachment> をカンマ区切りで指定できます。それぞれの画像には先頭から順番に <attachment> の値が適用されます。

+このプロパティは複数の背景画像に対応しており、それぞれの背景画像に異なる `` をカンマ区切りで指定できます。それぞれの画像には先頭から順番に `` の値が適用されます。 -

HTML

+#### HTML -
<p>
+```html
+

There were doors all round the hall, but they were all locked; and when Alice had been all the way down one side and up the other, trying every door, she walked sadly down the middle, wondering how she was ever to @@ -96,56 +99,32 @@ background-attachment: unset; time round, she came upon a low curtain she had not noticed before, and behind it was a little door about fifteen inches high: she tried the little golden key in the lock, and to her great delight it fitted! -</p>

+

+``` -

CSS

+#### CSS -
p {
-  background-image: url("https://mdn.mozillademos.org/files/12057/starsolid.gif"),
-      url("https://mdn.mozillademos.org/files/12059/startransparent.gif");
+```css
+p {
+  background-image: url("starsolid.gif"),
+      url("startransparent.gif");
   background-attachment: fixed, scroll;
   background-repeat: no-repeat, repeat-y;
-}
- -

結果

- -

{{EmbedLiveSample("Multiple_background_images")}}

- -

仕様書

- - - - - - - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('CSS3 Backgrounds', '#the-background-attachment', 'background-attachment')}}{{Spec2('CSS3 Backgrounds')}}複数の背景画像と local に対応するために一括指定プロパティを拡張。
{{SpecName('CSS2.1', 'colors.html#propdef-background-attachment', 'background-attachment')}}{{Spec2('CSS2.1')}}重要な変更なし。
{{SpecName('CSS1', '#background-attachment', 'background-attachment')}}{{Spec2('CSS1')}}重要な変更なし。
- -

ブラウザーの互換性

- -

{{Compat("css.properties.background-attachment")}}

- -

関連情報

- - +} +``` + +#### 結果 + +{{EmbedLiveSample("Multiple_background_images")}} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- [複数の背景画像を使う](/ja/docs/Web/CSS/CSS_Backgrounds_and_Borders/Using_multiple_backgrounds) -- cgit v1.2.3-54-g00ecf