Why CSS Media Query doesn't work on mobile device but yes on Google Chrome device emulator?

南笙酒味 提交于 2020-01-06 02:30:15

问题


As from the title, I don't understand why the media query works on emulator device on Google Chrome and it doesn't work on a real mobile device.

Html meta tag

<meta name="viewport" content="width=max-width, initial-scale=1, maximum-scale=1, user-scalable=no">

Css:

@media screen and (min-device-width:640px) and (max-device-width:767px){...}

Actually I've set up the min and max resolutions from 640/768/850/1024 for mobile devices screen resolution, but it seems be an error, cause .... I don't understand yet


回答1:


You should apply device width in meta viewport

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">



回答2:


The CSS should be like the following and check:

@media screen and (min-width:640px) and (max-width:767px){...}


来源:https://stackoverflow.com/questions/24329258/why-css-media-query-doesnt-work-on-mobile-device-but-yes-on-google-chrome-devic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!