27
loading...
This website collects cookies to deliver better user experience
@media
media query.@media (condition) {
CSS styles;
}
@media
and after that we have to give condition or you can check for media device. Let's take some examples.@media screen and (max-width: 500px){
.element{
styles;
}
}
@media
we used screen
keyword, this is used to define that you are checking screen. you can also type all | print | speech
. After that, you can see and
keyword, that and
means whenever there is a screen, and the condition is true, apply the styles. And the last we have the condition.@media (max-width: 500px){
.element{
stylessss;
}
}
max-width
: This means if you say max-width:500px
then the following style only be applied when the view port width is 500px or less.
min-width
: This is the reverse of max-width
. It means if you say min-width:500px
then the following style only be applied when the view port width is 500px or more.
/* Extra small devices (phones, 600px and down) */
@media (max-width: 600px) {...}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media (min-width: 600px) {...}
/* Medium devices (landscape tablets, 768px and up) */
@media (min-width: 768px) {...}
/* Large devices (laptops/desktops, 992px and up) */
@media (min-width: 992px) {...}
/* Extra large devices (large laptops and desktops, 1200px and up) */
@media (min-width: 1200px) {...}