blob: 16d2f850382d92be5a677f897009c1dbcfa4ec67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
---
title: '-webkit-device-pixel-ratio'
slug: Web/CSS/@media/-webkit-device-pixel-ratio
tags:
- '@media'
- CSS
- NeedsBrowserCompatibility
- Non-standard
- WebKit
- media feature
translation_of: Web/CSS/@media/-webkit-device-pixel-ratio
---
<div>{{ CSSRef }} {{ Non-standard_header }}</div>
<p><a href="/ja/docs/Web/CSS">CSS</a> の <strong><code>-webkit-device-pixel-ratio</code></strong> 標準外の真偽値<a href="/ja/docs/Web/CSS/Media_Queries/Using_media_queries#Media_features">メディア特性</a>は、標準の<a href="/ja/docs/Web/CSS/@media/resolution"><code>resolution</code></a>メディア特性の代替です。</p>
<div class="note">
<p><strong>注:</strong> このメディア特性は WebKit の機能です。可能であれば、代わりに <a href="/ja/docs/Web/CSS/@media/resolution"><code>resolution</code></a> メディア特性クエリを使用してください。</p>
</div>
<h2 id="Syntax" name="Syntax">構文</h2>
<p><code>-webkit-device-pixel-ratio</code> 特性は {{cssxref("<number>")}} 値で指定されます。これは範囲特性であり、つまり接頭辞が付いた <strong><code>-webkit-min-device-pixel-ratio</code></strong> 及び <strong><code>-webkit-max-device-pixel-ratio</code></strong> の変化形を使用して、それぞれ最低値と最高値をクエリすることもできます。</p>
<h3 id="Values" name="Values">値</h3>
<dl>
<dt>{{cssxref("<number>")}}</dt>
<dd>CSS の <a href="/ja/docs/Web/CSS/length#Absolute_length_units"><code>px</code></a> を表すために使われるデバイスピクセルの数です。この値は <code><number></code> であり、構文的に単位を許可しておらず、暗黙の単位は <a href="/ja/docs/Web/CSS/resolution#dppx"><code>dppx</code></a> です。</dd>
</dl>
<h2 id="Implementation" name="Implementation">実装</h2>
<pre class="brush: css notranslate">/* "dppx" の単位が含まれています。 */
@media (-webkit-min-device-pixel-ratio: 2) { ... }
/* ... は以下のものと同じです。 */
@media (min-resolution: 2dppx) { ... }
/* 同様に */
@media (-webkit-max-device-pixel-ratio: 2) { ... }
/* ... は以下のものと同じです。 */
@media (max-resolution: 2dppx) { ... }
</pre>
<h2 id="Examples" name="Examples">例</h2>
<h3 id="HTML">HTML</h3>
<pre class="brush: html notranslate"><p>This is a test of your device's pixel density.</p>
</pre>
<h3 id="CSS">CSS</h3>
<pre class="brush: css notranslate">/* 正確な解像度 */
@media (-webkit-device-pixel-ratio: 1) {
p {
color: red;
}
}
/* 最低解像度 */
@media (-webkit-min-device-pixel-ratio: 1.1) {
p {
font-size: 1.5em;
}
}
/* 最高解像度 */
@media (-webkit-max-device-pixel-ratio: 3) {
p {
background: yellow;
}
}</pre>
<h3 id="Result" name="Result">結果</h3>
<p>{{EmbedLiveSample("Example")}}</p>
<h2 id="Specifications" name="Specifications">仕様書</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">仕様書</th>
<th scope="col">状態</th>
<th scope="col">備考</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('Compat', '#css-media-queries-webkit-device-pixel-ratio', '-webkit-device-pixel-ratio')}}</td>
<td>{{Spec2('Compat')}}</td>
<td>初回の標準化</td>
</tr>
<tr>
<td><a class="external external-icon" href="https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariCSSRef/Articles/OtherStandardCSS3Features.html#//apple_ref/doc/uid/TP40007601-SW3" hreflang="en" lang="en">Safari CSS Reference<br>
<small lang="en-US">'media query extensions' in that document.</small></a></td>
<td>標準外の非公式文書</td>
<td>初回の文書化</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
<p>{{Compat("css.at-rules.media.-webkit-device-pixel-ratio")}}</p>
<h2 id="See_also" name="See_also">関連項目</h2>
<ul>
<li><a href="/ja/docs/Web/CSS/Media_Queries/Using_media_queries">メディアクエリの利用</a></li>
<li>{{cssxref("resolution")}}</li>
<li><a href="/ja/docs/Web/CSS/@media/-webkit-transform-2d"><code>-webkit-transform-2d</code></a></li>
<li><a href="/ja/docs/Web/CSS/@media/-webkit-transform-3d"><code>-webkit-transform-3d</code></a></li>
<li><a href="/ja/docs/Web/CSS/@media/-webkit-transition"><code>-webkit-transition</code></a></li>
<li><a href="/ja/docs/Web/CSS/@media/-webkit-animation"><code>-webkit-animation</code></a></li>
<li><a href="https://www.w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio/">W3C Suggested Method to UnPrefix</a></li>
</ul>
|