Why use media queries ? The different to the %
Question by Ruwantha
I know that media queries are use to create responsive layouts. But My question is we can do the same thing using ” % “. So my question is then why media queries?
Answer by Starx
Defining layout using %
help create a fluid layout, NOT RESPONSIVE layouts.
Media queries help you to define different style sets for different screen sizes.
Also with Media Queries, you don’t have to be limited to just heights and weights, you can control more than sizes.
Example below creates different background for different screen sizes:
@media only screen and (min-width: 320px) {
body {
background: red;
}
}
@media only screen and (min-width: 780px) {
body {
background: blue;
}
}
Can %
do that?
No