简体   繁体   English

媒体查询不适用于移动设备

[英]Media Query Isn't Working On Mobile

I'm currently working on a site that is supposed to change between different stylesheets based on the size of the screen. 我目前正在一个应该根据屏幕大小在不同样式表之间进行更改的网站上。 It works perfectly when I test this on my laptop browser, changing styles as I resize the width of the browser window, but it doesn't work on my mobile phone. 当我在笔记本电脑的浏览器上进行测试时,它可以完美地工作,可以在更改浏览器窗口的宽度时更改样式,但不适用于手机。 I'm only getting the desktop stylesheet, and I'm not sure why. 我只得到桌面样式表,但不知道为什么。 The phone I'm using to view the site is a Samsung Galaxy S4, and appears the same on both Firefox and Chrome. 我用来查看站点的电话是Samsung Galaxy S4,在Firefox和Chrome上都显示相同。

<link rel="stylesheet" type="text/css" media="screen and (min-width:1200px)" href="css/styles_desk.css">
<link rel="stylesheet" type="text/css" media="screen and (min-width: 768px) and (max-width: 1024px)" href="css/styles_tablet.css">
<link rel="stylesheet" type="text/css" media="screen and (min-width: 320px) and (max-width: 480px)" href="css/styles_mobile.css">

确保设置了视口

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

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM