mobile only media query 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
@media only screen and (min-width: 768px) {
.my-example-class {
padding: 50px;
}
}
@media (min-width: 576px) { ... }
@media (min-width: 768px) { ... }
@media (min-width: 992px) { ... }
Example 3: mobile tablet desktop media queries
Syntax:
@media( media feature ) {
}
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
Example 4: media query for mobile landscape only
@media screen and (orientation:landscape) and
(min-device-width: 320px) and (max-device-width: 450px) {
}
Example 5: media queries
@media all and (max-width: 699px) and (min-width: 520px) {
ul li a {
padding-left: 21px;
background: url(../images/email.png) left center no-repeat;
}
}