@media css code example
Example 1: css media queries
@media only screen and (max-width: 1200px){
/*Tablets [601px -> 1200px]*/
}
@media only screen and (max-width: 600px){
/*Big smartphones [426px -> 600px]*/
}
@media only screen and (max-width: 425px){
/*Small smartphones [325px -> 425px]*/
}
Example 2: media query
@media only screen and (max-width: 600px) {
body {
background-color: lightblue;
}
}
Example 3: css media query
/* BOOSTRAP MEDIA BREAKPOINTS */
/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
.selector {
background-color:#f00;
}
}
/* Medium devices (tablets, 768px and up) The navbar toggle appears at this breakpoint */
@media (min-width: 768px) {}
/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {}
/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {}
Example 4: min and max width media query
@media (max-width: 989px) and (min-width: 768px) {}
Example 5: media queries les plus utilisees
/* Sur les écrans, quand la largeur de la fenêtre fait au maximum 1280px */
@media screen and (max-width: 1280px)
/* Sur tous types d'écran, quand la largeur de la fenêtre est comprise entre 1024px et 1280px */
@media all and (min-width: 1024px) and (max-width: 1280px)
/* Sur les téléviseurs */
@media tv
/* Sur tous types d'écrans orientés verticalement */
@media all and (orientation: portrait)
Example 6: orientation css max and min width media query
<style type="text/css">
@media only screen and (min-width: 960px) {
}
@media only screen and (min-width: 1440px) {
}
@media only screen and (min-width: 2000px) {
}
@media only screen and (max-device-width: 480px) {
}
@media only screen and (device-width: 768px) {
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
}
</style>