On Github fernandoporazzi / css3-techparty-2014
Design Responsivo é um conceito de estruturação de HTML e CSS para deixar o site adaptável às mais diversas resoluções de tela.
Em julho de 2013 existiam 11.868 tipos distintos de smartphones rodando Android.
Media Queries detectam o tamanho da tela do usuário e aplicam o CSS conforme necessário.
<link rel="stylesheet" href="/css/reset.css"> <link rel="stylesheet" href="/css/grid.css">
Adicione essa tag no cabeçalho do html, assim habilitamos o uso de media queries.
<meta name="viewport" content="width=device-width, initial-scale=1">
Descreve como os elementos são gerados e se comportam no navegador. Esse conceito consiste em 4 diferentes partes:
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
@media screen and (min-width: 320px) and (max-width: 480px) {
// code here
}
@media screen and (min-width: 480px) and (max-width: 568px) {
// code here
}
@media screen and (min-width: 568px) and (max-width: 768px) {
// code here
}
@media screen and (min-width: 768px) and (max-width: 1024px) {
// code here
}
@media screen and (min-width: 1024px) and (max-width: 1200px){
// code here
}
@media screen and (min-width: 1200px){
// code here
}
window.matchMedia()
var mq = window.matchMedia('@media all and (max-width: 700px)');
if (mq.matches) {
// largura maior que 700px
} else {
// largura menor que 700px
}
mq.addEventListener()
mq.addEventListener(function(changed){
if (changed.matches) {
// largura maior que 700px
} else {
// largura menor que 700px
}
});
Temos tempo?