Media Queries For Mobile, Laptop, Desktop And iPad For Making Responsive Website Design

Media Query

Media query is a CSS technique introduced in CSS3.

It uses the @media rule to include a block of CSS properties only if a certain condition is true.

Media queries enable us to create a responsive website design (RWD) where specific styles are applied to small screens, large screens, and anywhere in between. The media query syntax allows for the creation of rules that can be applied depending on device characteristics.

General Syntax of Media Query

@media (query) {
   /* CSS Rules used when query matches */
}


While there are several different items we can query on, the ones used most often for responsive web design are min-width, max-width, min-height and max-height.

Let's have a look at device specific queries:

1. Mobile

There are two different resolution for laptops.
  1. /* For 480 Resolution */  
  2. @media only screen   
  3. and (min-device-width : 320px)   
  4. and (max-device-width : 480px)  
  5. /* STYLES GO HERE */}  
resolution

Generally, this dimension is recommended for mobile:
  1. /* For 640 Resolution */  
  2. @media only screen   
  3. and (min-device-width : 360px)   
  4. and (max-device-width : 640px)  
  5. /* STYLES GO HERE */}  
mobile

2. Laptop

There are two different resolution for laptops.
  1. /* For 1024 Resolution */  
  2. @media only screen   
  3. and (min-device-width : 768px)   
  4. and (max-device-width : 1024px)  
  5. /* STYLES GO HERE */}  
Program
  1. /* For 1366 Resolution */  
  2. @media only screen   
  3. and (min-width: 1030px)   
  4. and (max-width: 1366px)  
  5. /* STYLES GO HERE */}  
Code

Generally, this dimension is recommended for laptop,

3. Desktop
  1. @media only screen   
  2. and (min-width: 1370px)  
  3. and (max-width: 1605px)  
  4. /* STYLES GO HERE */}  
STYLES

4. iPad
  1. /* If you're looking to supply different graphics or choose different typography for the lower resolution iPad display, the media queries below will work. */  
  2. /* Orientation : Landscape */  
  3. @media only screen   
  4. and (orientation : landscape)   
  5. and (-webkit-min-device-pixel-ratio: 1)  
  6. and (min-device-width : 768px)   
  7. and (max-device-width : 1007px)   
  8. /* STYLES GO HERE */}  
run
  1. /* Orientation : Portrait */  
  2. @media only screen   
  3. and (orientation : portrait)   
  4. and (-webkit-min-device-pixel-ratio: 1)   
  5. and (min-device-width : 768px)   
  6. and (max-device-width : 1007px)  
  7. /* STYLES GO HERE */}  
STYLES GO HERE

I have attached sample .css file in this article. Guys, keep exploring. If you have any queries, please feel free to contact me.

Up Next
    Ebook Download
    View all
    Learn
    View all