Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在缩略图悬停时显示图像预览_Jquery_Image - Fatal编程技术网

Jquery 如何在缩略图悬停时显示图像预览

Jquery 如何在缩略图悬停时显示图像预览,jquery,image,Jquery,Image,如果您转到此页面上的inspect元素并设置float:right,我将使用显示图像预览;并将鼠标悬停在离窗口最近的图像上,预览图像将隐藏在屏幕后面。我希望它显示在左边,如果悬停的图像在最右边,反之亦然。感谢您的帮助 下面是处理mouseover和mousemove的js /* * Image preview script * powered by jQuery (http://www.jquery.com) * * written by Alen Grakalic (htt

如果您转到此页面上的inspect元素并设置float:right,我将使用显示图像预览;并将鼠标悬停在离窗口最近的图像上,预览图像将隐藏在屏幕后面。我希望它显示在左边,如果悬停的图像在最右边,反之亦然。感谢您的帮助

下面是处理mouseover和mousemove的js

    /*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

this.imagePreview = function(){ 
    /* CONFIG */

        xOffset = 10;
        yOffset = 30;

        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result

    /* END CONFIG */
    $("a.preview").hover(function(e){
        this.t = this.title;
        this.title = "";    
        var c = (this.t != "") ? "<br/>" + this.t : "";
        $("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");                                
        $("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px")
            .fadeIn("fast");                        
    },
    function(){
        this.title = this.t;    
        $("#preview").remove();
    }); 
    $("a.preview").mousemove(function(e){
        $("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px");
    });         
};


// starting the script on page load
$(document).ready(function(){
    imagePreview();
});
/*
*图像预览脚本
*由jQuery提供支持(http://www.jquery.com)
* 
*作者:阿伦·格拉卡里克(http://cssglobe.com)
* 
*欲了解更多信息,请访问http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*
*/
this.imagePreview=函数(){
/*配置*/
xOffset=10;
yOffset=30;
//这两个变量确定弹出窗口与光标的距离
//您可能需要调整以获得正确的结果
/*结束配置*/
$(“a.preview”).hover(函数(e){
this.t=this.title;
this.title=“”;
var c=(this.t!=”)?“
”+this.t:”; $(“正文”)。追加(“

”+c+”

”; $(“预览”) .css(“顶部”(e.pageY-xOffset)+“px”) .css(“左”(e.pageX+yOffset)+“px”) .fadeIn(“快速”); }, 函数(){ this.title=this.t; $(“#预览”).remove(); }); $(“a.preview”).mousemove(函数(e){ $(“预览”) .css(“顶部”(e.pageY-xOffset)+“px”) .css(“左”(e.pageX+yOffset)+“px”); }); }; //在页面加载时启动脚本 $(文档).ready(函数(){ 图像预览(); });
我写了一些不同的东西,然后仔细阅读了你的问题:(我希望它仍然会对你有所帮助。你所要做的就是去掉Math.min,并使用一个简单的IF,当它为真时,稍微更改偏移量

trc_x = Math.min(trc_x + event.pageX, Mx);
trc_y = Math.min(trc_y + event.pageY, My);