Default CSS overriding media query

前端 未结 1 458
无人共我
无人共我 2020-12-20 11:27

I\'m getting this from Chrome ADB plugin, connecting to my phone via USB. Basically allowing me to inspect elements on my android chrome and view or alter them on my connect

相关标签:
1条回答
  • 2020-12-20 11:48

    I thought media queries were to overrule generic class rules,

    Rules inside a MQ are rules like any other one in terms of priority of their selector, except they will only apply depending on the conditions of the at-media.

    (...) I also realize that the rule for non-media-queried container h1 is declared AFTER the media query rule.

    You found the correct reason: both rules have exactly the same priority (specificity) as they have the exact same selector. If a property is part of both rules (and the declaration is valid and both of them or none of them has !important modifier), then the value of the last declaration written will apply.
    That's the reason you'll always find MQ written at the end (except rules applying to IE8- via conditional classes, no possible overlap between MQ and modern browsers and IE8- :) )

    0 讨论(0)
提交回复
热议问题