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

滚动时将图像显示在另一个图像的顶部

  •  3
  • talkingD0G  · 技术社区  · 16 年前

    我想在某些图像上显示一个缩放图像(在鼠标上方)来暗示“单击此处缩放”。我不想用光标。

    我确信javascript jQuery有一个很好的方法可以做到这一点,但我不知道。

    有人有什么好主意吗?

    3 回复  |  直到 16 年前
        1
  •  3
  •   Thom Smith    16 年前

    HTML格式:

    <a href='big.jpg'>
        <img src='mini.jpg' alt='a kitten'>
        <span>Click to view larger</span>
    </a>
    

    CSS格式:

    a > img + span {display: none}
    a:hover > img + span {display: inline}
    

    那就随你的便。

        2
  •  1
  •   Marko    16 年前

    This jQuery plugin 似乎做你想做的,你可以很容易地定制它来满足你的需要(即实现点击)。

        3
  •  0
  •   GitaarLAB    11 年前

    http://www.worldtimzone.com/mozilla/testcase/css3cursors.html )但是你将不得不面对IE上的问题。也许你可以有一个带有自定义缩放图标的隐藏div,如: <div style="display:none" id="zoomcursor">yourcursor</div> 然后可以使用图像和jquery:

    $('img.zoomthis').mouseover(function(){
        var pos = $(this).position();
        $('#zoomcursor').css("position","absolute");
        $('#zoomcursor').css("top",pos.top+18);//You have to change this in order to place it right over your image
        $('#zoomcursor').css("left",$(obj).width()-30); //this too
        $('#zoomcursor').show();
    }).mouseout(function(){
        $('#zoomcursor').hide();
    })