I tried to rotate an image in javascript using the new Image()
I tried with this:
this.gunner = new Image()
this.gunner.src = *url*
this.gunner.style.WebkitTransform = "rotate(20deg)"
but the image still was like normal.
How can I do this?
I tried to rotate an image in javascript using the new Image()
I tried with this:
this.gunner = new Image()
this.gunner.src = *url*
this.gunner.style.WebkitTransform = "rotate(20deg)"
but the image still was like normal.
How can I do this?
Share Improve this question asked Mar 11, 2017 at 14:29 SIMONE ESPOSITOSIMONE ESPOSITO 771 silver badge8 bronze badges 3- which browser are you testing this? – CaptainHere Commented Mar 11, 2017 at 14:34
- I'm testing it in chrome – SIMONE ESPOSITO Commented Mar 11, 2017 at 14:36
- 1 Possible duplicate of Rotate a div using javascript – Banzay Commented Mar 11, 2017 at 14:39
1 Answer
Reset to default 3Try this:
var image = new Image();
image.src = 'http://placehold.it/350x150';
document.body.append(image);
image.style.transform = "rotate(90deg)";