简体   繁体   English

@media查询在桌面浏览器中起作用,而不在移动浏览器中起作用

[英]@media query works in desktop browser, not in mobile browser

I recently updated my site to make it mobile friendly. 我最近更新了我的网站 ,使其移动友好。 On my laptop, when I physically make the browser window smaller or larger, the @media queries fire and change the CSS. 在我的笔记本电脑上,当我实际缩小或放大浏览器窗口时,@ media查询将触发并更改CSS。 However, on my actual mobile browser, I'm getting the desktop site. 但是,在我的实际移动浏览器上,我正在获取桌面站点。 Can someone please tell me what's going on? 有人可以告诉我发生了什么吗?

Include in the 包括在

<meta name="viewport" content="width=device-width, initial-scale=1">

And it will work 它会起作用

You should add <meta name="viewport" content="width=device-width, initial-scale=1"> in you webpage. 您应该在网页中添加<meta name="viewport" content="width=device-width, initial-scale=1">
so that the virtual viewport matches the device dimensions. 使虚拟视口与设备尺寸匹配。

Add the Meta tag into your head section of your website. 将Meta标签添加到您网站的头部。 You will want to place the Meta tag below the other Meta tags in your head section or above your title tag. 您将需要将Meta标签放在头部的其他Meta标签之下或标题标签之上。

Without a viewport meta tag, your site will be rendered into the device's default virtual viewport. 没有视口元标记,您的网站将呈现到设备的默认虚拟视口中。

This Meta tag tells the mobile device to not zoom. 此Meta标签告诉移动设备不要缩放。 This allows the Responsive Template for mobile devices to be loaded in the scripts. 这允许在脚本中加载移动设备的响应模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Javascript 适用于桌面,但不适用于移动浏览器 - Javascript works on desktop but not on mobile browser JQM在桌面浏览器上工作而不是在移动设备上 - JQM works on desktop browser not mobile Javascript函数在桌面上可用,在移动浏览器上失败 - Javascript function works on Desktop, fails on mobile browser 我的Angular JS应用程序可在桌面浏览器中使用,但不能在移动浏览器中使用 - My Angular JS app works in desktop browser, but not in a mobile browser 导航按钮突出显示在桌面浏览器中有效,但在android移动浏览器中无效 - Nav button highlight works in desktop browser, but not in android mobile browser 在单击时关闭Bootstrap Popover:在桌面浏览器中工作正常,但在移动浏览器中工作不正常 - Bootstrap Popover Dismiss on Click: Works fine in desktop browser but not in mobile browser 手机桌面浏览器模拟器 - Desktop Browser Simulators for Mobile 查询可在浏览器桌面中使用但不能在移动设备中使用的JavaScript代码 - query mobile code javascript working in browser desktop but not in mobile 带有ng-pattern的AngularJS验证可在桌面浏览器中使用,但不能在移动设备上使用 - AngularJS validation with ng-pattern works in desktop browser but not mobile 浏览器卡在媒体查询上 - Browser Stuck On Media Query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM