Ver Mensaje Individual
  #7 (permalink)  
Antiguo 02/08/2010, 11:03
LLap
 
Fecha de Ingreso: marzo-2009
Mensajes: 39
Antigüedad: 15 años, 1 mes
Puntos: 1
Respuesta: background-image, backround-size - no funciona bien

Hola de nuevo. Perdón por tardar en responder pero estoy que no me lo atrapo xD

Lo que comentas DaChux puede ser interesante aunque no se si se notaria mas lenta la web.
Aún así no he sabido aplicarlo para probar ya que de javascript no se casi nada (lo mínimo) y con las indicaciones que me has dado no se como empezar.

Había intentado algo, pero muchas imágenes no se si no cargaban a tiempo o que pasaba pero la función tamaño me devolvía 0, 0 y claro no se mostraban:

Código:
var i = new Image();
	i.src = source;
	var w =i.width;
	var h = i.height;
	var t = tamaño(120, 190, w, h);
	
	var code = sprintf( '<div class=\"tr\"><a class=\"clicka\" href=\"%s\"
  title=\"%s\"><span class=\"thumb_p\" > <img src=\"%s\" %s> </span>%s</a>
</div>', url, _data.title, img, mides,  _data.title );
Código:
function tamaño(maxWidth , maxHeight, w, h) {
  

  if (w > maxWidth || h > maxHeight) {
  if (w > h) {
    h = (h * maxWidth) / w;
    w = maxWidth;
  }
  else {
    w = (w * maxHeight) / h;
    h = maxHeight;
  }
}

var tam= sprintf ('width=\"%s px\" height=\"%s px\"', w, h);
return 	tam;
}

Última edición por LLap; 02/08/2010 a las 11:12