我在标题中构建了一个 wp 模板:
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9">
在样式表中我使用@media 查询,例如:
@media only screen and (min-width: 1100px) {
#wrapper {width:1280px;}
}
样式和模板都很好,直到我注意到我错过了文档类型,所以我将其添加到标题中,如下所示:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9">
并非所有样式都不正确,媒体查询似乎被忽略了,我在开发人员检查器(Firefox、chrome、safari 等)中看不到任何样式。
如果我删除了显示的媒体查询中的样式,请再次添加它,样式将被删除。
问题在所有浏览器上都可见。
有什么明显的我遗漏的吗?
最佳答案
Doctype 对您的媒体查询没有影响。
不过您可以添加一些支持。
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--[if lt IE 9]>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
<meta name="viewport" content="width=device-width; initial-scale=1.0">
这些将提供跨浏览器引用支持,很可能会解决您的问题。
查看类似帖子:CSS3 Media Queries - does not work in some browsers (officially supporting MQ)
关于html - <!DOCTYPE html> 删除媒体查询样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28718413/