CSS media queries min-width and min-device-width conflicting?

前端 未结 2 1027
旧时难觅i
旧时难觅i 2020-11-30 01:49

I am very new to the world of media queries, and it\'s clear there\'s something fundamental I\'m missing about the difference between width and device-width -- other than th

相关标签:
2条回答
  • 2020-11-30 02:20

    device-width is deprecated in Media Queries Level 4. Refer to MDN docs here for more details.

    So, width and height features should be used to consider the width and height of the viewport respectively.

    P.S. These are range features they can be prefixed with min- or max- to express "minimum condition" or "maximum condition" constraints. Reference here.

    0 讨论(0)
  • 2020-11-30 02:35

    Device-width refers to the display's resolution (eg. the 1024 from 1024x768), while width refers to the width of the browser itself (which will be different from the resolution if the browser isn't maximized). If your resolution is large enough to get you in one break point, but the width of the browser is small enough to get you in another one, you'll end up with an odd combination of both.

    Unless you have a legitimate reason to restrict the style sheets based on the resolution and not the size of the viewport, then just use min-width/max-width and avoid min-device-width/max-device-width.

    0 讨论(0)
提交回复
热议问题