5

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?

3
  • which browser are you testing this? Commented Mar 11, 2017 at 14:34
  • I'm testing it in chrome Commented Mar 11, 2017 at 14:36
  • 1
    Possible duplicate of Rotate a div using javascript Commented Mar 11, 2017 at 14:39

1 Answer 1

3

Try this:

var image = new Image();
image.src = 'http://placehold.it/350x150';
document.body.append(image);
image.style.transform = "rotate(90deg)";

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.