From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/css/max-width/index.html | 142 ++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 files/ja/web/css/max-width/index.html (limited to 'files/ja/web/css/max-width') diff --git a/files/ja/web/css/max-width/index.html b/files/ja/web/css/max-width/index.html new file mode 100644 index 0000000000..7638cb8443 --- /dev/null +++ b/files/ja/web/css/max-width/index.html @@ -0,0 +1,142 @@ +--- +title: max-width +slug: Web/CSS/max-width +tags: + - CSS + - CSS Property + - CSS プロパティ + - Reference +translation_of: Web/CSS/max-width +--- +
{{CSSRef}}
+ +

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

+ +
{{EmbedInteractiveExample("pages/css/max-width.html")}}
+ + + +

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

+ +

構文

+ +
/* <length> 値 */
+max-width: 3.5em;
+
+/* <percentage> 値 */
+max-width: 75%;
+
+/* キーワード値 */
+max-width: none;
+max-width: max-content;
+max-width: min-content;
+max-width: fit-content(20em);
+
+/* グローバル値 */
+max-width: inherit;
+max-width: initial;
+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, 引数)) です。
+
+ +

形式文法

+ +
{{csssyntax}}
+ +

+ +

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

+ +
+
<div id="parent">
+  <div id="child">
+    Fusce pulvinar vestibulum eros, sed luctus ex lobortis quis.
+  </div>
+</div>
+
+ +
#parent {
+  background: lightblue;
+  width: 300px;
+}
+
+#child {
+  background: gold;
+  width: 100%;
+  max-width: 150px;
+}
+
+
+ +

{{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")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf