本文介绍了Chrome设备模式仿真媒体查询不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于某些原因,设备仿真模式不会读取我的媒体查询。它适用于其他网站,包括我自己的网站,我用bootstrap,但它不工作在我从头开始使用的媒体查询(点击媒体查询按钮,蓝色按钮,但没有显示媒体查询)。测试文件。这是Chrome中的错误还是我需要在我的文件中更改的内容?
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?
<!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>
推荐答案
我通过添加元标记page:
I fixed this problem by adding a meta tag to my page:
<meta name="viewport" content="width=device-width">
这篇关于Chrome设备模式仿真媒体查询不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!