jQuery实现鼠标划过展示大图的方法
这篇文章主要介绍了jQuery实现鼠标划过展示大图的方法,实例分析了jQuery操作鼠标事件及图片处理的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了jQuery实现鼠标划过展示大图的方法。分享给大家供大家参考。具体如下:
这里用css和jquery实现鼠标移上元素时大图展示,并且大图不能溢出整个div框
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery鼠标划过展示大图</title>
<style type="text/css">
* { margin:0; padding:0; }
body { font:12px/1.5 tahoma, arial, simsun; }
.wrap { position:relative; margin:0 auto; width:319px; height:243px; }
table { border-collapse:collapse; border-spacing:0; }
td { border:1px solid #ccc; background:#f0f0f0; width:80px; height:80px; }
td div { position:relative; width:100%; height:100%; background:#eee; }
td b { display:block; position:relative; z-index:20; width:20px; height:20px; background:#fff; }
td a.s { display:block; position:absolute; z-index:10; left:0; top:0; height:100%; width:100%; text-indent:-999em; overflow:hidden; background:url(Images/nb/8080logo.jpg) no-repeat; }
#hideBox { display:none; position:absolute; width:140px; height:120px; background:#fff; border:1px solid #333; z-index:300; }
#hideBox a { display:block; height:100%; width:100%; }
</style>
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var wrapWidth = $(".wrap").width();
var wrapHeight = $(".wrap").height();
var boxWidth = $("#hideBox").outerWidth();
var boxHeight = $("#hideBox").outerHeight();
$("td a").mouseover(function(){
var pos = $(this).parent("div").position();
var toLeft = wrapWidth - (boxWidth + pos.left);
var toTop = wrapHeight - (boxHeight + pos.top);
if(toLeft>0){
$("#hideBox").css({left:pos.left});
}
else if(toLeft<0){
$("#hideBox").css({left:wrapWidth-boxWidth});
}
if(toTop>0){
$("#hideBox").css({top:pos.top});
}
else if(toTop<0){
$("#hideBox").css({top:wrapHeight-boxHeight});
}
$("#hideBox").show();
});
$("#hideBox").mouseout(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<div class="wrap">
<table>
<tr>
<td><div><b>15</b><a id="g1" class="s" href="#">名称1</a></div></td>
<td><div><b>16</b><a id="g2" href="#">名称2</a><br />
<a id="g3" href="#">名称3</a></div></td>
<td><div><b>15</b><a id="g3" class="s" href="#">名称1</a></div></td>
<td><div><b>15</b><a id="g4" class="s" href="#">名称1</a></div></td>
</tr>
<tr>
<td><div><b>15</b><a id="g5" class="s" href="#">名称1</a></div></td>
<td><div><b>15</b><a id="g6" class="s" href="#">名称1</a></div></td>
<td><div><b>16</b><a id="g7" href="#">名称2</a><br />
<a id="g8" href="#">名称3</a></div></td>
<td><div><b>16</b><a id="g9" href="#">名称2</a><br />
<a id="g3" href="#">名称3</a></div></td>
</tr>
<tr>
<td><div><b>16</b><a id="g11" href="#">名称2</a><br />
<a id="g12" href="#">名称3</a></div></td>
<td><div><b>16</b><a id="g13" href="#">名称2</a><br />
<a id="g14" href="#">名称3</a></div></td>
<td><div><b>15</b><a id="g15" class="s" href="#">名称1</a></div></td>
<td><div><b>15</b><a id="g16" class="s" href="#">名称1</a></div></td>
</tr>
</table>
<div id="hideBox"><a href="">大图展示</a></div>
</div>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
jQuery实现鼠标划过展示大图的方法的更多相关文章
- jQuery制作鼠标经过显示图片大图,生成图片tips效果
一般tips都是文字,这个可以支持图片,很漂亮: 演示 <script type="text/javascript"> // Load this script on ...
- jQuery实现鼠标悬停显示提示信息窗口的方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 关闭myeclipse中烦人的鼠标划过,自动提示功能
eclipse越来越智能,身为码农的我却越来越伤心.虽然你很智能,但请你提供一些有用的信息给我,不要乱七八槽的,不问青红皂白就塞一大堆提示给我,对不起,哥不需要这些!!! 都知道,使用myeclips ...
- 鼠标划过用户名时在鼠标右下角显示div展示用户资料
最近做一个网站论坛,为了方便会员之间相互了解,又不想再做一个页面展示用户资料,就想到了鼠标划过用户名时在鼠标右下角显示div展示用户资料这个效果, 这里要注意的该方法不是给每个用户名的旁边都绑定一个d ...
- 鼠标划过图片title 提示实现
鼠标划过图片title 提示实现 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "h ...
- JS/jquery实现鼠标控制页面元素显隐
最近网站要上一个活动广告横幅,当用户鼠标划过时显隐二维码.像这种鼠标事件控制页面元素显隐的情况,码农们会经常遇到,可以通过javascript或jquery代码实现,下面就几种常见需求一起归纳一下. ...
- 【前端图表】echarts散点图鼠标划过散点显示信息
在做项目的过程中,总会遇到这样或者那样的bug,这个时候就要看自己的动手能力有多强了,着手解决了一个bug之后,整个人都感觉很开心,端午下班之前遇到了一个小问题,echarts散点图鼠标划过散点的时候 ...
- jQuery css3鼠标悬停图片显示遮罩层动画特效
jQuery css3鼠标悬停图片显示遮罩层动画特效 效果体验:http://hovertree.com/texiao/jquery/39/ 效果图: 源码下载:http://hovertree.co ...
- jQuery实现鼠标经过图片变亮效果
在线体验效果:http://hovertree.com/texiao/jquery/1.htm 以下是完整源代码: <!DOCTYPE html PUBLIC "-//W3C//DTD ...
随机推荐
- Java-idea-运行tomcat 报內存溢出 PermGen space
错误:OutOfMemoryError: PermGen space 非堆溢出(永久保存区域溢出) 在Run/Debug configuration 的你要运行行的tomcat里面的 vm optio ...
- 【转】Deep Learning(深度学习)学习笔记整理系列之(三)
好了,到了这一步,终于可以聊到Deep learning了.上面我们聊到为什么会有Deep learning(让机器自动学习良好的特征,而免去人工选取过程.还有参考人的分层视觉处理系统),我们得到一个 ...
- Winzip和Winrar命令行的使用
Winzip和Winrar除了提供丰富灵活的图形界面操作功能外,二者都还具备从命令行模式进行文件的压缩与解压缩操作功能,极大的方便了我们在批处理文件中调用压缩软件.以下给出了二者的常用命令行使用方法: ...
- Python ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。
问题怎么出现的: 电脑是win8 64位,,下载了一个mysqldb 32位,http://sourceforge.net/projects/mysql-python/files/latest/dow ...
- [转]AJAX 跨源 HTTP 请求
转自OSChina, 原文: http://www.oschina.net/translate/ajax-cross-origin-http-request 背景 跨源HTTP请求(也称跨域AJAX请 ...
- 两个栈实现队列&两个栈实现队列
为说明思想,假设队列.栈都很大,不会出现满的情况. 1. 两个栈实现队列 //前提已知: struct Stack { int top; //栈顶指针 int stacksize;//栈的大小 int ...
- 1.初步认识JVM -- JVM序列
1.JVM概念 JVM是java Virtual Machine的简称.也称为Java虚拟机. 虚拟机:通过软件模拟具有完整硬件功能的运行在一个完全隔离环境的完整计算机系统.VMWare.Visual ...
- Codeforces Round #265 (Div. 2) E
这题说的是给了数字的字符串 然后有n种的操作没次将一个数字替换成另一个字符串,求出最后形成的字符串的 数字是多大,我们可以逆向的将每个数推出来,计算出他的值和位数记住位数用10的k次方来记 1位就是1 ...
- React 函数传参
import React, { Component } from 'react'; import { render } from 'react-dom'; class GroceryList exte ...
- mongo增删改查封装(C#)
Framework版本:.Net Framework 4 ConnectionUtil源码参见:https://www.cnblogs.com/threadj/p/10536273.html usin ...