可以在没有画布或 AJAX 的情况下通过 JavaScript 旋转图像吗?

发布于 2024-07-14 04:52:34 字数 195 浏览 11 评论 0原文

我见过一些 JavaScript 图像旋转器使用 HTML5 画布元素或对服务器端脚本的 AJAX 调用,但是是否可以在不使用这些方法的情况下完成此操作? Internet Explorer 不支持canvas(我知道excanvas,但如果可能的话我希望不支持canvas)并且我不确定AJAX 是否足够流畅。 如果有办法的话,是否有任何开源脚本、示例或资源可供我参考?

I've seen a few JavaScript image rotators that use either the HTML5 canvas element or an AJAX call to a server-side script, but is it possible to do it without using those methods? Internet Explorer doesn't support canvas (I'm aware of excanvas, but I'd like to do without if possible) and I'm not sure if AJAX will be fluid enough. If there is a way, are there any open source scripts, examples, or resources that you could point me to?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

童话 2024-07-21 04:52:34

唉,CSS 不支持以任何方式、形状或形式旋转图像(除非您计算 CSS 变换,仅 Safari 4 和 Firefox 3.1 支持)。

你最好的选择是使用Raphael的image()和rotate(),它应该支持所有半现代浏览器(使用 SVG)和大多数版本的 IE(使用 VML)。

Alas, CSS does not support rotating images in any way, shape or form (unless you count CSS Transforms, which are only supported by Safari 4 and Firefox 3.1).

Your best bet is to use Raphael's image() and rotate(), which should support all semi-modern browsers (using SVG) and most versions of IE (using VML).

旧人九事 2024-07-21 04:52:34

This jQuery plugin works in major browsers including IE: http://wilq32.googlepages.com/wilq32.rollimage222 . It makes use of excanvas, but at least it allows you to evaluate if that method is good enough for your purposes.

月棠 2024-07-21 04:52:34

是的,通过 CSS 转换:

 var degree=180;
 document.getElementById('image_name').style.transform='rotate('+degree+'deg)';

Yes, via CSS Transform:

 var degree=180;
 document.getElementById('image_name').style.transform='rotate('+degree+'deg)';
檐上三寸雪 2024-07-21 04:52:34

谷歌是你的朋友:
http://www.walterzorn.com/rotate_img/rotate_img.htm

但缺点这种技术(如前所述)的特点是它通过插入大量 DIVS 来使用 hack,因此它可能会稍微减慢浏览器的速度。 谨慎使用。 像这样的问题就是创建canvas标签的首要原因。

Google is your friend:
http://www.walterzorn.com/rotate_img/rotate_img.htm

But the downside of this technique (as mentioned) is that it uses hacks by inserting a huge number of DIVS so it could slow down the browser a good bit. Use with caution. Problems like this are why the canvas tag was created in the first place.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文