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/@media/aspect-ratio/index.html | 126 ++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 files/ja/web/css/@media/aspect-ratio/index.html (limited to 'files/ja/web/css/@media/aspect-ratio/index.html') diff --git a/files/ja/web/css/@media/aspect-ratio/index.html b/files/ja/web/css/@media/aspect-ratio/index.html new file mode 100644 index 0000000000..e8e8e36864 --- /dev/null +++ b/files/ja/web/css/@media/aspect-ratio/index.html @@ -0,0 +1,126 @@ +--- +title: aspect-ratio +slug: Web/CSS/@media/aspect-ratio +tags: + - '@media' + - CSS + - Reference + - メディアクエリ + - メディア特性 +translation_of: Web/CSS/@media/aspect-ratio +--- +
{{cssref}}
+ +

CSSaspect-ratio メディア特性は、{{glossary("viewport", "ビューポート")}}のアスペクト比を調べるために使用します。

+ +

構文

+ +

aspect-ratio 特性は、ビューポートの幅対高さのアスペクト比を表現する {{cssxref("<ratio>")}} 値で指定します。これは範囲の特性であり、つまり接頭辞の付いた min-aspect-ratio および max-aspect-ratio の変化形を使用して、それぞれ最小値と最大値をクエリすることができます。

+ +

+ +

以下の例は独自のビューポートを生成する {{htmlElement("iframe")}} に含まれています。 <iframe> の大きさを変更して aspect-ratio の変化を確認してください。

+ +

HTML

+ +
<div id='inner'>
+  ビューポートの幅と高さを変更しながら、この要素を見ていてください。
+</div>
+
+ +

CSS

+ +
/* 最小アスペクト比 */
+@media (min-aspect-ratio: 8/5) {
+  div {
+    background: #9af; /* blue */
+  }
+}
+
+/* 最大アスペクト比 */
+@media (max-aspect-ratio: 3/2) {
+  div {
+    background: #9ff;  /* cyan */
+  }
+}
+
+/* 正確なアスペクト比。上書きを防ぐために最下部に配置 */
+@media (aspect-ratio: 1/1) {
+  div {
+    background: #f9a; /* red */
+  }
+}
+
+ + + +

結果

+ +
+

{{ EmbedLiveSample('_Example', '300px', '400px') }}

+
+ +

仕様書

+ + + + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('CSS4 Media Queries', '#aspect-ratio', 'aspect-ratio')}}{{Spec2('CSS4 Media Queries')}}変更なし
{{SpecName('CSS3 Media Queries', '#aspect-ratio', 'aspect-ratio')}}{{Spec2('CSS3 Media Queries')}}初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("css.at-rules.media.aspect-ratio")}}

-- cgit v1.2.3-54-g00ecf