简体   繁体   English

媒体查询无法在Chrome中使用,但可以在Firefox中使用

[英]Media Queries not working in Chrome, works in Firefox

I have a whole range of stylesheets that are specific to many different resolutions. 我有一系列针对各种不同分辨率的样式表。 I link to them using references in the header, such as: 我使用标题中的引用链接到它们,例如:

<link rel="stylesheet" media="(min-width: 1024px) and (max-width: 1024px)" href="http://site.com/child-theme/1024.css" />

In Firefox they work without a hitch, but in Chrome (and possibly Safari) it doesn't honor the media queries, even though it clearly detects/sees them as they are viewable in Firebug, however they are crossed out. 在Firefox中,它们可以正常工作,但是在Chrome(可能还有Safari)中,它不支持媒体查询,即使它可以在Firebug中清晰可见地检测到/看到它们,也可以将它们删除。

Can't for the life of me figure it out... any help solving this puzzle would be much appreciated! 无法为我的生活弄清楚...解决这个难题的任何帮助将不胜感激!

My (wordpress) site is: HBB-Inc.com To view how it should look, check it out in Firefox... and then compare in Chrome. 我的(wordpress)网站是: HBB-Inc.com要查看其外观,请在Firefox中查看它,然后在Chrome中进行比较。

It's because of the nature of CSS , it stands for C ascading S tyle S heets . 这是因为CSS的性质,代表C ascading 小号 tyle 小号 heets。

An amended quote on this from a number of places on the internet: 互联网上许多地方对此的修订报价:

Cascade is the special part. 级联是特殊的部分。 A style sheet is intended to cascade through a series of style rules, like a river over a waterfall. 样式表旨在通过一系列样式规则进行级联,例如瀑布上的河流。 The water in the river hits all the rocks in the waterfall, but only the ones at the bottom affect exactly where the water will flow. 河流中的水撞击瀑布中的所有岩石,但只有底部的岩石会影响水的确切流动位置。 The same is true of the cascade in style sheets. 样式表中的层叠也是如此。

In other words, because your media="all" style sheets are linked lower down in your head section they are affecting the look of the very same elements which you have styled earlier in the process. 换句话说,因为您的media="all"样式表在您的头部下方是向下链接的,所以它们会影响您之前在流程中样式相同的元素的外观。

I think moving the style sheets with their media attribute set to all to the start of your head section will fix your problem 我认为将样式表及其media属性设置为all到头部的开头将解决您的问题

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

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