このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

device-width

Deprecated

Avoid using this feature in new projects. Device media queries do not reflect available layout, only the physical size of the device. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: Media queries.

メモ: ビューポートの幅を問い合わせる場合は、代わりに width メディア特性を使用してください。

device-widthCSSメディア特性で、出力機器の描画面の幅を調べるために使用することができます。

構文

device-width 特性は、 <length> 値として指定します。これは範囲の特性であり、つまり接頭辞の付いた min-device-width および max-device-width の変化形を使用して、それぞれ最小値と最大値をクエリーすることができます。

800 ピクセルより狭い機器に特別のスタイルシートを適用

html
<link
  rel="stylesheet"
  media="screen and (max-device-width: 799px)"
  href="https://cdn.example.com/narrow-styles.css" />

仕様書

仕様書
Media Queries Level 4
# device-width

ブラウザーの互換性

関連情報