Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to negate @media min/max-width/height? [duplicate]

I use http://www.w3.org/TR/css3-mediaqueries/ to have different design depending on the available viewport.

In order for my search-and-replace to work, for every time I decide to adjust the cut-off points, I'd like to clearly negate @media (min-width: 500px), which intersects on (max-width: 500px), and, therefore, has to be manually negated as (max-width: 499px) instead, which then breaks search-and-replace.

I've tried not (min-width: 500px), but it doesn't seem to work at all. Is there a way to negate @media (min-width: 500px), such that the negative query will still have 500px in it, for my search-and-replace to work?

like image 577
cnst Avatar asked Apr 12 '16 21:04

cnst


People also ask

Which of the following is used to negate the entire media query result?

The not operator is used to negate an entire media query. The only operator is used to apply a style only if the entire query matches, useful for preventing older browsers from applying selected styles.

Is Min-width Max width inclusive?

Remember that the min- and max- prefixes mean "minimum inclusive" and "maximum inclusive"; this means (min-width: 20em) and (max-width: 20em) will both match a viewport that is exactly 20em wide.

What does this code do @media only screen and max width?

@media only screen and (max-width: 600px) and (min-width: 400px) {...} The query above will trigger only for screens that are 600-400px wide. This can be used to target specific devices with known widths. CSS Tricks has an up to date list of standard device widths and the media queries to use.

What is the difference between @media and @media only screen?

@media is the actually media query. The word screen is adding the 'conditions' to the media query. So @media screen is telling the media query to apply (whatever other conditions) to screens. For example, @media screen and (max-width: 360px) will target only screens with a max-width of 360px.


1 Answers

Try this

@media not all and (min-width: 500px) {
  //selectors
}

You may also try depending upon your needs,

@media not screen and (device-width:500px)

This doesn't work

 not (min-width: 500px) {}

https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries

like image 180
master_dodo Avatar answered Oct 10 '22 02:10

master_dodo