Possible causes for mobile browser to render differently than a scaled-down PC browser?

♀尐吖头ヾ 提交于 2019-12-11 07:44:23

问题


GOAL:
Stylize a chat-interface on mobile devices.

PROBLEM:
I've thrown together a proof-of-concept for a chatbot. Everything is very simple, including the JS & CSS. While I'm also having a separate issue with JS (i think), this here is my CSS problem.

While developing, I tested in FF & Chrome, and scaled down the browsers to emulate the mobile-browser experience.
All the CSS media queries acted as expected.

Yet ...on any mobile device we test, the sizing specified in CSS media queries has no effect and we are left having to zoom in.

EXAMPLE:
temp.mosaranch.com/chatbot-tester

QUESTION:
What could cause mobile browsers to not render specific media-query CSS rules, while the rules are applied when scaling down on a desktop browser?


回答1:


You need a viewport meta tag in order for media queries to work properly on mobile devices.

Read more at MDN:
https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag

A typical mobile-optimized site contains something like the following:
<meta name="viewport" content="width=device-width, initial-scale=1">



来源:https://stackoverflow.com/questions/46434818/possible-causes-for-mobile-browser-to-render-differently-than-a-scaled-down-pc-b

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