模拟google相册鼠标移动提示信息

简介:

在jQuery中文社区中看到一篇帖子提问,http://bbs.jquery.org.cn/read.php?tid-3992.html

模拟google的照片鼠标提示信息

下面介绍如何实现:

1、在html中增加两个img


<img src="panda.jpg" border="0" alt="" width="231" height="300" />
<img src="no.jpg" alt="" width="231" height="300" />


2、准备一个提示信息使用的DIV层

<div id="tipInfo" style="display:none"></div>

这里一定要主意把tipInfo的position设置为absolute,我在做的时候就卡到这里了,后来发现原来忘了设置……

3、javascript代码:


$(function() {
        //$('#content img:not(:eq(0))')的意思是不显示第一张图片的信息
    $('#content img:not(:eq(0))').hover(
        function() {
            var position = $(this).position();
            var tipHight = $('#tipInfo').height();

            var endTop = (position.top + $(this).height()) - tipHight;
            //$(this).addClass('active');
            $("#tipInfo").width($(this).width())
                .html('作者:' + $(this).attr('author'))
                .show()
                .css({top: endTop + "px", left: position.left + "px"});
        },
        function() {
            //$(this).removeClass('active');
            $('#tipInfo').hide();
        }
    );
});


测试通过,代码很简单,点击这里查看演示

源码[download#12#format=1]

相关文章
|
Web App开发 JavaScript iOS开发
仿Google+相册的动画
在使用Google+的时候,查看某一相册,会经常看到,如下图所示的动画效果。 鼠标移入、移出时均有动画效果,咋一看估计是使用了css3的transform属性来实现动画效果的。 在网上搜索“Google+ 相册 效果”的时候发现有人使用CSS3做了这样的效果,不过使用调试工具查看节点元素的时候,我觉得它是使用JS在进行的控制。
672 0
|
2月前
|
数据可视化 定位技术 Sentinel
如何用Google Earth Engine快速、大量下载遥感影像数据?
【2月更文挑战第9天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,批量下载指定时间范围、空间范围的遥感影像数据(包括Landsat、Sentinel等)的方法~
351 0
如何用Google Earth Engine快速、大量下载遥感影像数据?
|
2月前
|
编解码 人工智能 算法
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
21 0
|
2月前
|
编解码 人工智能 数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
41 0
|
2月前
|
编解码
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
19 0
|
2月前
Google Earth Engine(GEE)——导出指定区域的河流和流域范围
Google Earth Engine(GEE)——导出指定区域的河流和流域范围
38 0
|
2月前
|
传感器 编解码 数据处理
Open Google Earth Engine(OEEL)——哨兵1号数据的黑边去除功能附链接和代码
Open Google Earth Engine(OEEL)——哨兵1号数据的黑边去除功能附链接和代码
22 0
|
2月前
Google Earth Engine(GEE)——当加载图表的时候出现错误No features contain non-null values of “system:time_start“.
Google Earth Engine(GEE)——当加载图表的时候出现错误No features contain non-null values of “system:time_start“.
37 0

热门文章

最新文章