CSS Tutorial
Menu
CSS Advanced
Menu
CSS Responsive
Menu
CSS Grid
Menu
Responsive Web design -Media Queries
What is a Media Query?
Media query is a CSS technique that was introduced in CSS3.
It uses the @media rule to include a block of CSS properties only if a specified condition is true.
Example
If the browser window is 600px or smaller, the background color will be lightblue:
Resize the browser window to see the effect!
The media query will only apply if the media type is screen and the viewport is 480px wide or wider.
CSS
body {
background-color: pink;
}
@media screen and (min-width: 480px) {
body {
background-color: lightgreen;
}
}
Output
Resize the browser window to see the effect!
The media query will only apply if the media type is screen and the viewport is 480px wide or wider.