Media Query For Tablet And Mobile Code Example


Example 1: media query for mobile view css

@media only screen and (max-width: 600px) {   body {     background-color: lightblue;   } }

Example 2: media query desktop

/* Extra small devices (phones, 600px and down) */ @media only screen and (max-width: 600px) {...}  /* Small devices (portrait tablets and large phones, 600px and up) */ @media only screen and (min-width: 600px) {...}  /* Medium devices (landscape tablets, 768px and up) */ @media only screen and (min-width: 768px) {...}  /* Large devices (laptops/desktops, 992px and up) */ @media only screen and (min-width: 992px) {...}  /* Extra large devices (large laptops and desktops, 1200px and up) */ @media only screen and (min-width: 1200px) {...}

Example 3: media querries for tablets

/* ----------- iPad 1, 2, Mini and Air ----------- */  /* Portrait and Landscape */ @media only screen    and (min-device-width: 768px)    and (max-device-width: 1024px)    and (-webkit-min-device-pixel-ratio: 1) {  }  /* Portrait */ @media only screen    and (min-device-width: 768px)    and (max-device-width: 1024px)    and (orientation: portrait)    and (-webkit-min-device-pixel-ratio: 1) {  }  /* Landscape */ @media only screen    and (min-device-width: 768px)    and (max-device-width: 1024px)    and (orientation: landscape)    and (-webkit-min-device-pixel-ratio: 1) {  }  /* ----------- iPad 3, 4 and Pro 9.7" ----------- */  /* Portrait and Landscape */ @media only screen    and (min-device-width: 768px)    and (max-device-width: 1024px)    and (-webkit-min-device-pixel-ratio: 2) {  }  /* Portrait */ @media only screen    and (min-device-width: 768px)    and (max-device-width: 1024px)    and (orientation: portrait)    and (-webkit-min-device-pixel-ratio: 2) {  }  /* Landscape */ @media only screen    and (min-device-width: 768px)    and (max-device-width: 1024px)    and (orientation: landscape)    and (-webkit-min-device-pixel-ratio: 2) {  }  /* ----------- iPad Pro 10.5" ----------- */  /* Portrait and Landscape */ @media only screen    and (min-device-width: 834px)    and (max-device-width: 1112px)   and (-webkit-min-device-pixel-ratio: 2) {  }  /* Portrait */ /* Declare the same value for min- and max-width to avoid colliding with desktops */ /* Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/ @media only screen    and (min-device-width: 834px)    and (max-device-width: 834px)    and (orientation: portrait)    and (-webkit-min-device-pixel-ratio: 2) {  }  /* Landscape */ /* Declare the same value for min- and max-width to avoid colliding with desktops */ /* Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/ @media only screen    and (min-device-width: 1112px)    and (max-device-width: 1112px)    and (orientation: landscape)    and (-webkit-min-device-pixel-ratio: 2) {  }  /* ----------- iPad Pro 12.9" ----------- */  /* Portrait and Landscape */ @media only screen    and (min-device-width: 1024px)    and (max-device-width: 1366px)   and (-webkit-min-device-pixel-ratio: 2) {  }  /* Portrait */ /* Declare the same value for min- and max-width to avoid colliding with desktops */ /* Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/ @media only screen    and (min-device-width: 1024px)    and (max-device-width: 1024px)    and (orientation: portrait)    and (-webkit-min-device-pixel-ratio: 2) {  }  /* Landscape */ /* Declare the same value for min- and max-width to avoid colliding with desktops */ /* Source: https://medium.com/connect-the-dots/css-media-queries-for-ipad-pro-8cad10e17106*/ @media only screen    and (min-device-width: 1366px)    and (max-device-width: 1366px)    and (orientation: landscape)    and (-webkit-min-device-pixel-ratio: 2) {  }

Example 4: mobile tablet desktop media queries

Syntax:  @media( media feature ) {     // CSS Property }  The screen resolutions of different devices are listed below:  Mobile (Smartphone) max-width: 480px Low Resolution Tablets and ipads max-width: 767px Tablets Ipads portrait mode max-width:1024px Desktops max-width:1280px Huge size (Larger screen) max-width: 1281px and greater

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?