Why does `not (some-width: Xem)` media query never fire?

Septagram

I'm trying to negate the max-device-width media query (the reason for this is I don't won't both (max-device-width: X) and (min-device-width: X) to fire if the device has precisely that width). Unfortunately, the not (min-or-max-some-width: X) media queries never fire.

Here's a small fiddle. I expect two yellow lines on the desktop and two red lines on mobile. What I get is only one yellow line on the desktop (the last one) and only one red line on mobile (the first one).

What am I doing wrong?

BoltClock

When Media Queries was first introduced, it required the not keyword to be followed by a media type in order for the media query to be valid. It seems strange, but that's just how the grammar was defined (see the media_query production).

This is now fixed in Media Queries level 4 (see the <media_not> production), so what you have should work as expected in browsers that conform to MQ4. However, none of the browsers that have begun shipping level 4 media features has implemented the new grammar yet.

In the meantime, you'll need to add a media type. If the media type is not important, use all:

not all and (max-device-width: X)

Updated fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why does `not (some-width: Xem)` media query never fire?

From Dev

Why does MutationObserver fire twice for childList but never for characterData?

From Dev

Why does a media query with a smaller min-width overwrite a larger one?

From Dev

Why isn't the width or margin in my @media query registering properly?

From Dev

Why is width:100% relative to screen when within media query

From Dev

Why Are My Media Query's Instructions not Honored 100% On Some Devices

From Dev

AlarmManager does not fire on some devices?

From Java

$(window).width() not the same as media query

From Dev

using device width in media query

From Dev

PHP media query width in php

From Dev

Kindle Fire 8.9 HDX media query

From Dev

Kindle Fire 8.9 HDX media query

From Dev

why does a higher max-width in media queries overwrite a lower max-width?

From Dev

Why does CSS rotation in media query not rotate back

From Dev

Why does a css media query not match my phone

From Dev

Why does loadedmetadata not consistently fire

From Dev

Why does the ajax event not fire?

From Dev

Why does UILocalNotification with region not fire?

From Dev

Why does loadedmetadata not consistently fire

From Dev

CSS media query to detect width double the height?

From Dev

media query, browser width issue on mobile

From Dev

CSS media query for exact viewport width

From Dev

What will be the maximum width of tablet to use in media query?

From Dev

Width property on flex item not recognized in media query

From Dev

Media query min-width with Javascript code

From Dev

media query, browser width issue on mobile

From Dev

Media query in css not working for different width

From Dev

Media query for same width different heights

From Dev

media query max-width not working

Related Related

  1. 1

    Why does `not (some-width: Xem)` media query never fire?

  2. 2

    Why does MutationObserver fire twice for childList but never for characterData?

  3. 3

    Why does a media query with a smaller min-width overwrite a larger one?

  4. 4

    Why isn't the width or margin in my @media query registering properly?

  5. 5

    Why is width:100% relative to screen when within media query

  6. 6

    Why Are My Media Query's Instructions not Honored 100% On Some Devices

  7. 7

    AlarmManager does not fire on some devices?

  8. 8

    $(window).width() not the same as media query

  9. 9

    using device width in media query

  10. 10

    PHP media query width in php

  11. 11

    Kindle Fire 8.9 HDX media query

  12. 12

    Kindle Fire 8.9 HDX media query

  13. 13

    why does a higher max-width in media queries overwrite a lower max-width?

  14. 14

    Why does CSS rotation in media query not rotate back

  15. 15

    Why does a css media query not match my phone

  16. 16

    Why does loadedmetadata not consistently fire

  17. 17

    Why does the ajax event not fire?

  18. 18

    Why does UILocalNotification with region not fire?

  19. 19

    Why does loadedmetadata not consistently fire

  20. 20

    CSS media query to detect width double the height?

  21. 21

    media query, browser width issue on mobile

  22. 22

    CSS media query for exact viewport width

  23. 23

    What will be the maximum width of tablet to use in media query?

  24. 24

    Width property on flex item not recognized in media query

  25. 25

    Media query min-width with Javascript code

  26. 26

    media query, browser width issue on mobile

  27. 27

    Media query in css not working for different width

  28. 28

    Media query for same width different heights

  29. 29

    media query max-width not working

HotTag

Archive