最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - Rotate Image in JavaScript with new Image() - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 3

Try this:

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

发布评论

评论列表(0)

  1. 暂无评论