媒体查询不适用于移动设备
Media Query Isn't Working On Mobile
我目前正在开发一个网站,该网站应该根据屏幕大小在不同样式表之间进行切换。当我在我的笔记本电脑浏览器上测试它时,它工作得很好,当我调整浏览器的宽度时改变样式 window,但它在我的手机上不起作用 phone。我只得到桌面样式表,我不确定为什么。我用来查看网站的 phone 是三星 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">
我目前正在开发一个网站,该网站应该根据屏幕大小在不同样式表之间进行切换。当我在我的笔记本电脑浏览器上测试它时,它工作得很好,当我调整浏览器的宽度时改变样式 window,但它在我的手机上不起作用 phone。我只得到桌面样式表,我不确定为什么。我用来查看网站的 phone 是三星 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">