About responsive sites, pixels, and density

前端 未结 2 1516
执笔经年
执笔经年 2021-01-26 13:14

I have coded a responsive website, in which I have CSS media queries to detect the screen size(pixels) of the device the user is navigating with.

Just standard medias. E

2条回答
  •  感情败类
    2021-01-26 14:09

    @media (max-width: 1199px){
      /*code*/
    }
    

    The max-width property in the media query works a little different. It is not the resolution of the screen. It is equivalent css pixel.

    Here are a couple of articles.

    A pixel identity crisis.

    A pixel is not a pixel is not a pixel.

    moz media query page.

    If you want to target device resolution you should use

    @media all and (max-device-width: 320px) {
    
    }.
    

    max-device-width:This property measures the device-width. If you write css using media query using this it will get a little complex (mobiles tabs and even desktops can have 1080p resolution screens). In order to target device resolutions you might have to look into properties like -device-pixel-ratio , orientation and device-height to give better control of layouts

提交回复
热议问题