zoukankan      html  css  js  c++  java
  • jQuery实现鼠标放到图片上,放大图片

    <script src="../../Script/jquery-1.7.2.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $(".imgstate").hover(function (e) {
                    var screenWidth = $(window).width();
                    var screenHeight = $(window).height();
                    var imgWidth = $("#imgBigImg").width();
                    var imgHeight = $("#imgBigImg").height();
    
                    var strSrc = $(this).attr("bigSrc");
                    var tagX = $(this).offset().left + $(this).width();
                    //var tagY = $(this).offset().top + $(this).height();
                    if (tagX + imgWidth > screenWidth) {
                        tagX = tagX - imgWidth - 20;
                    }
                    else {
                        tagX = tagX + 200;
                    }
                    var sdf = document.documentElement.scrollTop;
                    var sdfd = ($(window).height() - imgHeight) / 2;
                    var tagY = ($(window).height() - imgHeight) / 2 + document.documentElement.scrollTop;
                    $("#imgBigImg").attr("src", strSrc);
                    $("#div_BigImg").css({ top: tagY, left: tagX }).show();
                }, function () {
                    //$("#imgBigImg").hide();
                    $("#div_BigImg").hide();
                });
            });
        </script>
    

      

    <div id="div_BigImg" style="z-index: 5;  600px; margin: 0px 0 0 -200px;
                position: absolute; text-align: center; padding: 20px; display: none;">
                <img id='imgBigImg' height="480px" width="600px" class="imgBigImg" src="" style=" 
                    padding: 0; margin: 0; cursor: pointer;" />
            </div>
            <table style=" 600px; margin: 0 auto; z-index: 0;">
                <tr>
                    <td>
                        <asp:DataList ID="dlModeList" runat="server" RepeatColumns="8" RepeatDirection="Horizontal"
                            Width="600px" DataKeyField="Id">
                            <ItemTemplate>
                                <table>
                                    <tr>
                                        <td style="height: 130px; vertical-align: top;">
                                            <asp:HyperLink ID="lnkTitleName3" runat="server" NavigateUrl='<%# Eval("UpFile", "~/{0}") %>'
                                                Target="_blank" ToolTip='<%# Eval("Name") %>'>
                                              <img class="imgstate" src='../../<%# Eval("UpFileThumbnail") %>' bigSrc='../../<%# Eval("Upfile") %>'  width="150px" height="130px" border="0"/>
                                            </asp:HyperLink>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="height: 35px; vertical-align: top;">
                                            <asp:Image ID="imgIconNew1" runat="server" ImageUrl="~/App_Themes/Default/Images/Icon/NewChs.gif"
                                                Visible='<%# zhy_CommClass.zhyPageView.HideItemByAddDate(Eval("AddDate"), 2) %>'>
                                            </asp:Image>
                                            <asp:HyperLink ID="lnkTitleName2" runat="server" NavigateUrl='<%# Eval("UpFile", "~/{0}") %>'
                                                Target="_blank"> <%# zhy_CommClass.zhyPageView.ShowStringFieldByMaxSize(Eval("Name"), 8) %>
                                            </asp:HyperLink>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                            <ItemStyle Width="155px" />
                        </asp:DataList>
                    </td>
                </tr>
          </table>
    

      

  • 相关阅读:
    【数学】三分法
    【数学】【背包】【NOIP2018】P5020 货币系统
    【数学】【CF27E】 Number With The Given Amount Of Divisors
    【单调队列】【P3957】 跳房子
    【极值问题】【CF33C】 Wonderful Randomized Sum
    【DP】【CF31E】 TV Game
    【神仙题】【CF28D】 Don't fear, DravDe is kind
    【线段树】【CF19D】 Points
    【字符串】KMP字符串匹配
    【二维树状数组】【CF10D】 LCIS
  • 原文地址:https://www.cnblogs.com/stevenjson/p/3445727.html
Copyright © 2011-2022 走看看