What is the difference between max-device-width and max-width for mobile web?

前端 未结 8 1960
盖世英雄少女心
盖世英雄少女心 2020-11-22 08:56

I need to develop some html pages for iphone/android phones, but what is the difference between max-device-width and max-width? I need to use diffe

相关标签:
8条回答
  • 2020-11-22 09:34

    the difference is that max-device-width is all screen's width and max-width means the space used by the browser to show the pages. But another important difference is the support of android browsers, in fact if u're going to use max-device-width this will work only in Opera, instead I'm sure that max-width will work for every kind of mobile browser (I had test it in Chrome, firefox and opera for ANDROID).

    0 讨论(0)
  • 2020-11-22 09:37

    Don't use device-width/height anymore.

    device-width, device-height and device-aspect-ratio are deprecated in Media Queries Level 4: https://developer.mozilla.org/en-US/docs/Web/CSS/@media#Media_features

    Just use width/height (without min/max) in combination with orientation & (min/max-)resolution to target specific devices. On mobile width/height should be the same as device-width/height.

    0 讨论(0)
  • 2020-11-22 09:40

    If you are making a cross-platform app (eg. using phonegap/cordova) then,

    Don't use device-width or device-height. Rather use width or height in CSS media queries because Android device will give problems in device-width or device-height. For iOS it works fine. Only android devices doesn't support device-width/device-height.

    0 讨论(0)
  • 2020-11-22 09:44

    max-device-width is the device rendering width

    @media all and (max-device-width: 400px) {
        /* styles for devices with a maximum width of 400px and less
           Changes only on device orientation */
    }
    
    @media all and (max-width: 400px) {
        /* styles for target area with a maximum width of 400px and less
           Changes on device orientation , browser resize */
    }
    

    The max-width is the width of the target display area means the current size of browser.

    0 讨论(0)
  • 2020-11-22 09:46

    max-width is the width of the target display area, e.g. the browser; max-device-width is the width of the device's entire rendering area, i.e. the actual device screen.

    • If you are using the max-device-width, when you change the size of the browser window on your desktop, the CSS style won't change to different media query setting;

    • If you are using the max-width, when you change the size of the browser on your desktop, the CSS will change to different media query setting and you might be shown with the styling for mobiles, such as touch-friendly menus.

    0 讨论(0)
  • 2020-11-22 09:52

    max-width is the width of the target display area, e.g. the browser

    max-device-width is the width of the device's entire rendering area, i.e. the actual device screen

    Same goes for max-height and max-device-height naturally.

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