Tema: Girar imagen
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/03/2012, 14:19
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Girar imagen

Otra posibilidad, manipulación de estilos:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<style>
#cont{ position:absolute; left:50%; top:50%; margin-top:-175px; margin-left:-250px; cursor:pointer; width:500px; height:350px;}
#cont img{ position:relative}
​</style>
<script type="text/javascript">
function rotate(angle){
    var rotation = Math.PI * angle / 180;
    var costheta = Math.cos(rotation);
    var sintheta = Math.sin(rotation); 
    if(!window.ActiveXObject){
        this.style.position='absolute';
        this.style.webkitTransform ='rotate('+angle+'deg)';
        this.style.khtmlTransform ='rotate('+angle+'deg)';  
        this.style.MozTransform='rotate('+angle+'deg)';    
        this.style.OTransform='rotate('+angle+'deg)';
        this.style.transform='rotate('+angle+'deg)';
    }else{
        this.style.filter="progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";
        this.filters.item(0).M11 = costheta;
        this.filters.item(0).M12 = -sintheta;
        this.filters.item(0).M21 = sintheta;
        this.filters.item(0).M22 = costheta; 
        this.style.top= ((this.parentNode.offsetHeight/2)-(this.offsetHeight/2))+'px';
        this.style.left=  ((this.parentNode.offsetWidth/2)-(this.offsetWidth/2))+'px';
    }
}
var ns={};
onload=function(){
        var _this=document.getElementById('im');
        ns.angulo=ns.angulo || 0;
        ns.timmer=setInterval(function(){rotate.call(_this,ns.angulo+=5)},30);
}
</script>

</head>

<body>
<div id="cont"><img id="im" src="http://www.disegnocentell.com.ar/arwen.jpg" width="500" height="350"  /></div>

</body>
</html>

Última edición por Panino5001; 02/03/2012 a las 14:32