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-position-x/index.md | 138 +++++++++++++----------- 1 file changed, 77 insertions(+), 61 deletions(-) (limited to 'files/ja/web/css/background-position-x') diff --git a/files/ja/web/css/background-position-x/index.md b/files/ja/web/css/background-position-x/index.md index b277e8f79f..4fcc1b79f9 100644 --- a/files/ja/web/css/background-position-x/index.md +++ b/files/ja/web/css/background-position-x/index.md @@ -3,33 +3,35 @@ title: background-position-x slug: Web/CSS/background-position-x tags: - CSS + - CSS 背景 - CSS プロパティ - - CSS 背景と境界 - Experimental - - Reference + - リファレンス + - recipe:css-property +browser-compat: css.properties.background-position-x translation_of: Web/CSS/background-position-x --- -
{{CSSRef}}
+{{CSSRef}} -

CSSbackground-position-x プロパティは、各背景画像における水平の初期位置を設定します。位置は {{cssxref("background-origin")}} によって設定された位置レイヤーに対する相対位置です。

+**`background-position-x`** は [CSS](/ja/docs/Web/CSS) のプロパティで、各背景画像における水平の初期位置を設定します。位置は {{cssxref("background-origin")}} によって設定された位置レイヤーに対する相対位置です。 -
{{EmbedInteractiveExample("pages/css/background-position-x.html")}}
+{{EmbedInteractiveExample("pages/css/background-position-x.html")}} - -

このプロパティの値は、その後で一括指定の {{cssxref("background")}} または {{cssxref("background-position")}} プロパティが定義されると上書きされます。

+このプロパティの値は、その後で一括指定の {{cssxref("background")}} または {{cssxref("background-position")}} プロパティが定義されると上書きされます。 -

構文

+## 構文 -
/* キーワード値 */
+```css
+/* キーワード値 */
 background-position-x: left;
 background-position-x: center;
 background-position-x: right;
 
-/* <percentage> 値 */
+/*  値 */
 background-position-x: 25%;
 
-/* <length> 値 */
+/*  値 */
 background-position-x: 0px;
 background-position-x: 1cm;
 background-position-x: 8em;
@@ -44,61 +46,75 @@ background-position-x: 0px, center;
 /* グローバル値 */
 background-position-x: inherit;
 background-position-x: initial;
+background-position-x: revert;
 background-position-x: unset;
-
+``` -

background-position-x プロパティは、1つ以上の値をカンマで区切って指定します。

+`background-position-x` プロパティは、1 つ以上の値をカンマで区切って指定します。 -

+### 値 -
-
left
-
背景画像の左端を、背景位置レイヤーの左端に配置します。
-
center
-
背景画像を背景位置レイヤーの方向の中央に配置します。
-
right
-
背景画像の右端を、背景位置レイヤーの右端に配置します。
-
{{cssxref("<length>")}}
-
指定された背景画像の左辺の、背景位置レイヤーの左辺からのオフセットです。 (ブラウザーによってはオフセットに右辺を割り当てることもできます)。
-
{{cssxref("<percentage>")}}
-
指定された背景画像の水平位置のオフセットで、コンテナーからの相対値です。 0% の値は背景画像の左端がコンテナーの左端の位置に配置されることを意味し、 100% の値は背景画像の右端が、コンテナーの右端の位置に配置されることを意味します。したがって、 50% の値では、背景画像を水平方向の中央に配置します。
-
+- `left` + - : 背景画像の左端を、背景位置レイヤーの左端に配置します。 +- `center` + - : 背景画像を背景位置レイヤーの方向の中央に配置します。 +- `right` + - : 背景画像の右端を、背景位置レイヤーの右端に配置します。 +- {{cssxref("<length>")}} + - : 指定された背景画像の左辺の、背景位置レイヤーの左辺からのオフセットです。 (ブラウザーによってはオフセットに右辺を割り当てることもできます)。 +- {{cssxref("<percentage>")}} + - : 指定された背景画像の水平位置のオフセットで、コンテナーからの相対値です。 0% の値は背景画像の左端がコンテナーの左端の位置に配置されることを意味し、 100% の値は背景画像の*右端*が、コンテナーの*右端*の位置に配置されることを意味します。したがって、 50% の値では、背景画像を水平方向の中央に配置します。 -

形式文法

+## 公式定義 + +{{cssinfo}} + +## 形式文法 {{csssyntax}} -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('CSS4 Backgrounds', '#background-position-longhands', 'background-position-x')}}{{Spec2('CSS4 Backgrounds')}}長年の実装に合わせるため、 {{cssxref("background-position")}} の個別指定サブプロパティを初回定義
- -

{{cssinfo}}

- -

ブラウザーの互換性

- -

{{Compat("css.properties.background-position-x")}}

- -

関連情報

- - +## 例 + +

基本的な例

+ +次の例は、シンプルな背景画像の実装で、background-position-x と background-position-y を使って、画像の水平方向と垂直方向の位置を別々に定義しています。 + +#### HTML + +```html +
+``` + +#### CSS + +```css +div { +  width: 300px; +  height: 300px; +  background-color: skyblue; +  background-image: url(https://media.prod.mdn.mozit.cloud/attachments/2020/07/29/17350/3b4892b7e820122ac6dd7678891d4507/firefox.png); +  background-repeat: no-repeat; +  background-position-x: center; +  background-position-y: bottom 10px; +} +``` + +#### 結果 + +{{EmbedLiveSample('Basic_example', '100%', 300)}} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- {{cssxref("background-position")}} +- {{cssxref("background-position-y")}} +- {{cssxref("background-position-inline")}} +- {{cssxref("background-position-block")}} +- [複数の背景の使用](/ja/docs/Web/CSS/CSS_Backgrounds_and_Borders/Using_multiple_backgrounds) -- cgit v1.2.3-54-g00ecf