From b878d4a1cf8abdbaef200f64391ed6af2d80c2a6 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 16 Nov 2021 10:16:30 +0900 Subject: CSS Box Sizing 関連のリファレンスを更新 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 2021/11/14 時点の英語版に同期 --- files/ja/web/css/max-width/index.md | 178 +++++++++++++++++------------------- 1 file changed, 82 insertions(+), 96 deletions(-) (limited to 'files/ja/web/css/max-width') diff --git a/files/ja/web/css/max-width/index.md b/files/ja/web/css/max-width/index.md index 89feb27342..b5dba1255b 100644 --- a/files/ja/web/css/max-width/index.md +++ b/files/ja/web/css/max-width/index.md @@ -3,27 +3,34 @@ title: max-width slug: Web/CSS/max-width tags: - CSS - - CSS Property - CSS プロパティ - - Reference + - レイアウト + - Limits + - 最大 + - リファレンス + - 寸法 + - max-width + - recipe:css-property + - size + - width +browser-compat: css.properties.max-width translation_of: Web/CSS/max-width --- -
{{CSSRef}}
+{{CSSRef}} -

max-widthCSS のプロパティで、要素の最大幅を設定します。これは {{Cssxref("width")}} プロパティの使用値が、 max-width で指定した値を上回ることを防ぎます。

+**`max-width`** は [CSS](/ja/docs/Web/CSS) のプロパティで、要素の最大幅を設定します。これは {{Cssxref("width")}} プロパティの[使用値](/ja/docs/Web/CSS/used_value)が、 `max-width` で指定した値を上回ることを防ぎます。 -
{{EmbedInteractiveExample("pages/css/max-width.html")}}
+{{EmbedInteractiveExample("pages/css/max-width.html")}} - +`max-width` は {{cssxref("width")}} を上書きしますが、 {{cssxref("min-width")}} は `max-width` を上書きします。 -

max-width は {{cssxref("width")}} を上書きしますが、 {{cssxref("min-width")}} は max-width を上書きします。

+## 構文 -

構文

- -
/* <length> 値 */
+```css
+/*  値 */
 max-width: 3.5em;
 
-/* <percentage> 値 */
+/*  値 */
 max-width: 75%;
 
 /* キーワード値 */
@@ -35,45 +42,60 @@ max-width: fit-content(20em);
 /* グローバル値 */
 max-width: inherit;
 max-width: initial;
+max-width: revert;
 max-width: unset;
-
- -

- -
-
{{cssxref("<length>")}}
-
max-width を絶対的な値で定義します。
-
{{cssxref("<percentage>")}}
-
max-width を包含ブロックの幅に対するパーセント値で定義します。
-
auto
-
ブラウザーは指定された要素の max-width を計算して選択します。
-
none
-
ボックスの寸法を制限しません。
-
max-content
-
内容物が推奨する max-width です。
-
min-content
-
内容物の最小の max-width です。
-
fit-content({{cssxref("<length-percentage>")}})
-
利用可能な空白を指定された引数で置き換えた fit-content 式を使用します。すなわち、 min(max-content, max(min-content, 引数)) です。
-
- -

形式文法

+``` + +### 値 + +- {{cssxref("<length>")}} + - : `max-width` を絶対的な値で定義します。 +- {{cssxref("<percentage>")}} + - : `max-width` を包含ブロックの幅に対するパーセント値で定義します。 +- `none` + - : ボックスの寸法を制限しません。 +- `max-content` + - : 内容物が推奨する `max-width` です。 +- `min-content` + - : 内容物の最小の `max-width` です。 +- `fit-content({{cssxref("<length-percentage>")}})` + - : 利用可能な空白を指定された引数で置き換えた `fit-content` 式を使用します。すなわち、 `min(max-content, max(min-content, 引数))` です。 + +## アクセシビリティの考慮 + +ページを拡大縮小して文字サイズを拡大した際に、 `max-width` を設定した要素が他のコンテンツを切り捨てたり妨げたりしないことを確認してください。 + +- [MDN "WCAG を理解する ― ガイドライン 1.4 の解説"](/ja/docs/Web/Accessibility/Understanding_WCAG/Perceivable#guideline_1.4_make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background) +- [Understanding Success Criterion 1.4.4 | W3C Understanding WCAG 2.0](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-scale.html) + +## 公式定義 + +{{cssinfo}} + +## 形式文法 {{csssyntax}} -

+## 例 + +

最大幅をピクセル単位で設定

+ +この例では、 "child" の幅が 150 ピクセルか "parent" の幅のどちらか小さい方になります。 -

この例では、 "child" の幅が150ピクセルか "parent" の幅のどちらか小さい方になります。

+#### HTML -
-
<div id="parent">
-  <div id="child">
+```html
+
+
Fusce pulvinar vestibulum eros, sed luctus ex lobortis quis. - </div> -</div> -
+
+ +``` + +#### CSS -
#parent {
+```css
+#parent {
   background: lightblue;
   width: 300px;
 }
@@ -83,58 +105,22 @@ max-width: unset;
   width: 100%;
   max-width: 150px;
 }
-
- +``` + +#### 結果 + +{{EmbedLiveSample("Setting_max_width_in_pixels", 350, 100)}} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 -

{{EmbedLiveSample("basic-max-width-demo", 350, 100)}}

- -

アクセシビリティの考慮事項

- -

ページを拡大縮小して文字サイズを拡大した際に、 max-width を設定した要素が他のコンテンツを切り捨てたり妨げたりしないことを確認してください。

- - - -

仕様書

- - - - - - - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('CSS4 Sizing', '#width-height-keywords', 'max-width')}}{{Spec2('CSS4 Sizing')}}
{{SpecName('CSS3 Sizing', '#width-height-keywords', 'max-width')}}{{Spec2('CSS3 Sizing')}}キーワード max-content, min-content, fit-content, fill-available を追加。
{{ SpecName('CSS2.1', 'visudet.html#min-max-widths', 'max-width') }}{{ Spec2('CSS2.1') }}初回定義
- -

{{cssinfo}}

- -

ブラウザーの互換性

- -

{{Compat("css.properties.max-width")}}

- -

関連情報

- - +- [ボックスモデル](/ja/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model), {{cssxref("box-sizing")}} +- {{cssxref("width")}}, {{cssxref("min-width")}} +- 対応する論理的プロパティ: {{cssxref("max-inline-size")}}, {{cssxref("max-block-size")}} -- cgit v1.2.3-54-g00ecf