Foro de elhacker.net

Programación => Desarrollo Web => Mensaje iniciado por: Drakaris en 10 Febrero 2018, 20:08 pm



Título: ¿Como optimizar mi fondo de página web para móviles y tablets?
Publicado por: Drakaris en 10 Febrero 2018, 20:08 pm
¿Como puedo ajustar mi fondo de web para moviles y tablets? en css.

Yo hice una función jQuery que al ser la pantalla de 600px me cambie el atributo "style":
Código:
$(document).ready(function(){
 if(window.matchMedia("(max-width: 600px)").matches){
    fondo12 = document.getElementById("fondo1");
    fondo12.setAttribute("style","background-image: url('imagenes/fondo_movil.jpg'); background-repeat:no-repeat; background-position: 0% 0%; background-attachment: fixed; background-size: 205% 205%;-webkit-background-size: 205% 205%; -moz-backgrou.nd-size:205% 205%; -o-background-size: 205% 205%; background-color:#F5ECCE;");
  }
});


Con eso conseguí ajustarlo al movil pero sé que no es así y no se como se hace. Y al hacer la función e cambiado de imagen fondo.jpg a fondo_movil.jpg

PD: Si puede ser css mejor, gracias.
Gracias de antemano.