For some reason device emulation mode is not reading my media queries. It works on other sites including my own sites that I made with bootstrap, but it's not working on media queries I am using from scratch (clicking the media queries button turns the button blue but no media queries are displayed). Test file below. Is this a bug in Chrome or is there something I need to change in my file?
由于某种原因,设备模拟模式不会读取我的媒体查询。它适用于其他网站,包括我自己使用bootstrap创建的网站,但它不能处理我从头开始使用的媒体查询(单击媒体查询按钮会将按钮变为蓝色但不显示媒体查询)。测试文件如下。这是Chrome中的错误还是我需要在文件中更改某些内容?
<!DOCTYPE html>
<!--
Media Queries Example 1
Sam Scott, Fall 2014
-->
<html>
<head>
<title>MQ Example 1</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font-family: sans-serif; }
h1 { color: red; }
h2 { color:blue; }
p { color:green; }
@media (max-width: 768px) and (min-width: 481px) {
h1 { color: green; }
h2 { color:red; }
p { color:blue; }
}
@media (max-width:479px), print {
h1,h2,p { color:black; }
}
@media print {
body { font-family: serif; }
}
</style>
</head>
<body>
<h1>I'm a first level heading</h1>
<p>I'm a paragraph.</p>
<h2>I'm a second level heading</h2>
<p>I'm another paragraph.</p>
</body>
</html>
2 个解决方案
#1
122
I fixed this problem by adding a meta tag to my page:
我通过在页面中添加元标记来解决此问题:
<meta name="viewport" content="width=device-width">
#2
5
Device emulation in Chrome is still a WIP. To be honest I think they pushed it to Chrome a little too soon. Try using Canary (the chrome beta browser) to test the emulation, I find that it's working way better than the one in Chrome.
Chrome中的设备模拟仍然是WIP。老实说,我认为他们很快就将它推向了Chrome。尝试使用Canary(chrome beta浏览器)来测试模拟,我发现它的工作方式比Chrome中的更好。
#1
122
I fixed this problem by adding a meta tag to my page:
我通过在页面中添加元标记来解决此问题:
<meta name="viewport" content="width=device-width">
#2
5
Device emulation in Chrome is still a WIP. To be honest I think they pushed it to Chrome a little too soon. Try using Canary (the chrome beta browser) to test the emulation, I find that it's working way better than the one in Chrome.
Chrome中的设备模拟仍然是WIP。老实说,我认为他们很快就将它推向了Chrome。尝试使用Canary(chrome beta浏览器)来测试模拟,我发现它的工作方式比Chrome中的更好。