Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Media Queries - Generic Responsive Templates


I want to create generic responsive templates, which media-queries
i have to use if i want to detect all the devices sizes?

like image 399
4EACH Avatar asked Mar 13 '14 05:03

4EACH


People also ask

Are media queries still used 2022?

Responsiveness is an important part of modern web development. However in the early days we had less number of devices and had the liberty to write as many media queries as we wanted. With time, the screen ratios changed and still keep evolving.

What is the difference between @media all and @media 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.


2 Answers

Check this Common CSS Media Queries Break Points

/*------------------------------------------
  Responsive Grid Media Queries - 1280, 1024, 768, 480
   1280-1024   - desktop (default grid)
   1024-768    - tablet landscape
   768-480     - tablet 
   480-less    - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }

@media all and (min-width: 768px) and (max-width: 1024px) { }

@media all and (min-width: 480px) and (max-width: 768px) { }

@media all and (max-width: 480px) { }


/* Portrait */
@media screen and (orientation:portrait) { /* Portrait styles here */ }
/* Landscape */
@media screen and (orientation:landscape) { /* Landscape styles here */ }


/* CSS for iPhone, iPad, and Retina Displays */

/* Non-Retina */
@media screen and (-webkit-max-device-pixel-ratio: 1) {
}

/* Retina */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
}

/* iPhone Portrait */
@media screen and (max-device-width: 480px) and (orientation:portrait) {
} 

/* iPhone Landscape */
@media screen and (max-device-width: 480px) and (orientation:landscape) {
}

/* iPad Portrait */
@media screen and (min-device-width: 481px) and (orientation:portrait) {
}

/* iPad Landscape */
@media screen and (min-device-width: 481px) and (orientation:landscape) {
}
like image 161
Sender Avatar answered Sep 18 '22 03:09

Sender


I highly recomend using Bootstrap. Faster development. Also documentation is very complete. http://getbootstrap.com/getting-started/

As for your question, you have this example:

/*Anything outside of media queries is for MOBILE
  This is Mobile first approach.
*/

/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) { ... }

/* Medium devices (desktops, 992px and up) */
@media (min-width: 992px) { ... }

/* Large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) { ... }
like image 39
adearriba Avatar answered Sep 20 '22 03:09

adearriba