What is a Media Query ?
Media query is a CSS technique introduced in CSS3.
It uses the @media rule to include a block of CSS properties only if a certain condition is true.
Web pages can be viewed using many devices like desktops, tablets and phones. Each device has its own unique resolutions and orientations
so it becomes important for web pages to look good in all screen sizes, it should not leave out an information to fit smaller screen but it should rather adapt its content to fit in any devices.
Syntax:
@media( media type ){
//code
}
Media type
media type can be defined as the device screen for which we are writing the code for.
In CSS we can target 3 type of media:
Syntax:
@media media_type and Width{
//code
}
@media screen and (min-width:800px){
#sidebar{display:none}
}
@media screen and (max-width:800px){
#sidebar{display:none}
}
We can use both together i.e we can give the desired start and end point.
@media screen and(min-width:320px) and (max-width:800px){
#sidebar{display:none}
}
above code will hide the sidebar from 320px - 800px