代码之家  ›  专栏  ›  技术社区  ›  TkTech

使用最小JQuery显示放大图像的最佳方法是什么?

  •  2
  • TkTech  · 技术社区  · 16 年前

    • 在mouseover(或:hover)上,将预览图像放大约400%,并将其显示在页面中心

      • 在FancyBox的例子中,它忽略了图像元素的宽度和高度,这使得它毫无用处
    • 大多数这些“灯箱”在被称为

    真的,我只是在寻找一个简单有效的解决方案。

    2 回复  |  直到 11 年前
        1
  •  0
  •   msemelman    16 年前

    试试这样的。诀窍是 position 你可以把沙发放在任何你想放的地方。 读点什么 here . 你可以读到悬停 here

    <!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" lang="en">
      <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
          <title>Test</title>
          <script text="text/javascript" 
              src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js">
          </script>
      </head>
      <body>
        <ul>
          <li class="">Lynx</li>
          <li>Jaguar</li>
        </ul>
        <div id="picture" style="position:absolute; top:0px; right:0px;">
        </div>
      <script type="text/javascript">
        var animal = {
            "Lynx": 
              "http://wnbaoutsiders.files.wordpress.com/2009/06/lynx21.jpg",
            "Jaguar" : 
              "http://www.tropical-rainforest-animals.com/image-files/jaguar.jpg"
          }
        var hovered = function(e) {
          //you can get what to show from the elemnt, instead of the content
          // you could use an id.
          var name = $(e.target).html()
          $('#picture').append("<img src='" + animal[name] +"'/>")
        }
        var unhovered = function() {
          $('#picture').empty();
        }
        //here you bind mouseenter and mouseleave
        $('li').hover(hovered, unhovered);
      </script>
      </body>
    
        2
  •  0
  •   ghoppe    16 年前

    也许你在找工具提示?您可以在工具提示中使用任何html(包括图像)。

    http://flowplayer.org/tools/tooltip/index.html