March 13, 2013

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

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!