Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply media query to only certain width range

How to apply a media query between 360px - 640px. This is overlapping my (max-width: 320px) mediaquery.

@media screen and (min-width:360px) and (max-width:640px) and (orientation : landscape)

My webpage where the problem occurs

like image 249
Vipin Tyagi Avatar asked May 27 '16 08:05

Vipin Tyagi


People also ask

How do I write a media query for a specific screen size?

Take a look: @media only screen and (min-width: 360px) and (max-width: 768px) { // do something in this width range. } The media query above will only work for the feature expression (the screen size of the mobile device that you're writing a style for) provided above.

How do you use media query min-width max width?

If you want to include both min and max width for responsiveness in the browser, then you can use the following: @media (min-width: 768px) and (max-width: 992px){...} @media (min-width: 480px) and (max-width: 767px) {...}

How do you make a media query 2 width?

“how to make a media query between two widths” Code Answer's@media only screen and (max-width: 600px) {...} @media only screen and (min-width: 600px) {...} @media only screen and (max-width: 600px) and (min-width: 400px) {...}

How do you set the width and height of a media query?

Use a comma to specify two (or more) different rules: @media screen and (max-width: 995px), screen and (max-height: 700px) { ... } Commas are used to combine multiple media queries into a single rule. Each query in a comma-separated list is treated separately from the others.


1 Answers

You don't have anything but this one media query in your page. If you want to change something under 320px you need to declare it separately. You should declare media queries that affect everything under the page width.

Here is a simple example of how media queries work: http://jsfiddle.net/ra9ry8t4/1/

It's probably easier to test in JSFiddle but here it is also as a snippet:

@media screen and (min-width: 480px) {
  body { 
    background-color: yellow;
  }
}

@media screen and (min-width: 320px) and (max-width:480px) {
  body { 
    background-color: blue;
  }
}

@media screen and (min-width: 320px) and (max-width:480px) and (orientation: landscape) {
  body { 
    background-color: green;
  }
}

@media screen and (max-width: 320px) {
  body { 
    background-color: red;
  }
}
<h1>Media Queries Example</h1>
<p>Increase or decrease the size of of this window to see the background color change</p>
like image 166
thepio Avatar answered Sep 28 '22 04:09

thepio