javascript 图像旋转

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %>

<!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 runat="server">
    <title></title>
    <script src="jquery-1.9.0.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <script>
            function a(obj) {
                if (!window.transform)
                    window.transform = 0;
                window.transform += 90;
                obj.style.transform = 'rotate(' + window.transform + 'deg)';
                if (window.transform % 180 == 0) {
                    $(obj).css("margin-top", 0);
                    $(obj).css("margin-left", 0);
                }
                else {
                    var len = ($(obj).width() - $(obj).height()) / 2;
                    $(obj).css("margin-top", len);
                    $(obj).css("margin-left", 0 - len);
                }
            }
        </script>
        <div onclick="a(this);" style="background:red;display:inline-block;"><asp:Image ID="Image1" runat="server" ImageUrl="~/img.gif" style="border:1px solid green;" /></div>
        
    
    </div>
    </form>
</body>
</html>

 

posted on 2020-03-24 15:30  空明流光  阅读(215)  评论(0编辑  收藏  举报

导航