2011-12-21 8 views

Respuesta

11

Esto debería hacer el trabajo

@media only screen and (min-width: 320px) { body{ font-size: 12px; } } 
@media only screen and (min-width: 768px) { body{ font-size: 14px; } } 
@media only screen and (min-width: 1024px) { body{ font-size: 16px; } } 
@media only screen and (min-width: 1900px) { body{ font-size: 18px; } } 
+0

Por qué está utilizando 'only screen' y vi que algunas personas usan' max-width'. –

+0

También puede incluir una hoja de estilos diferente para cada resolución de pantalla. O simplemente reduzca todo según los EM. Verifica esto para referencia. http://css-tricks.com/css-media-queries/ – wwwroth

+1

Recuerde que todavía necesita selectores dentro de los bloques de medios. Así que no sería 'font-size: 12px' sino' @media only screen y (min-width: 320px) {body {font-size: 12px}} ' – hradac

8

Me encanta this blog/website, ya que es un buen recurso para CSS3 y trucos ingeniosos:

/* Smartphones (portrait and landscape) ----------- */ 
@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) { 
/* Styles */ 
} 

/* Smartphones (landscape) ----------- */ 
@media only screen 
and (min-width : 321px) { 
/* Styles */ 
} 

/* Smartphones (portrait) ----------- */ 
@media only screen 
and (max-width : 320px) { 
/* Styles */ 
} 

/* iPads (portrait and landscape) ----------- */ 
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) { 
/* Styles */ 
} 

/* iPads (landscape) ----------- */ 
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) { 
/* Styles */ 
} 

/* iPads (portrait) ----------- */ 
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) { 
/* Styles */ 
} 

/* Desktops and laptops ----------- */ 
@media only screen 
and (min-width : 1224px) { 
/* Styles */ 
} 

/* Large screens ----------- */ 
@media only screen 
and (min-width : 1824px) { 
/* Styles */ 
} 

/* iPhone 4 ----------- */ 
@media 
only screen and (-webkit-min-device-pixel-ratio : 1.5), 
only screen and (min-device-pixel-ratio : 1.5) { 
/* Styles */ 
} 
+0

Entonces, ¿el ancho del dispositivo es para usar en dispositivos móviles y tabletas? –

+0

Creo que varía para las tabletas, ya que algunas funcionan como navegadores móviles (iPad, por ejemplo) y otras no. – Blender

0

Usted podría utilizar preguntas de los medios. Por ejemplo, su tamaño de fuente para 1024-1900 se establece así:

@media screen and (max-width: 1900px){ 
    body{font-size:16px;} 
} 

Para una explicación más detallada ver el diseño web receptivo: http://www.alistapart.com/articles/responsive-web-design/

+0

¿No se anulará a otros tamaños de pantalla inferior? –

+0

Lo he escrito, sí. Debería escribir otros selectores para resoluciones menores o agregar un 'y (mínimo ancho: 1200 px)' – hradac

1

aplicación de este código.

@media only screen and (max-width:319px) { body{font-size:11px}} 
@media only screen and (min-width:320px) and (max-width:767px) { body{font-size:12px} } 
@media only screen and (min-width:768px) and (max-width:1023px) { body{font-size:14px} } 
@media only screen and (min-width:1024px) and (max-width:1899px) { body{font-size:16px} } 
@media only screen and (min-width:1900px) { body{font-size:18px} } 
Cuestiones relacionadas