24小时免费服务热线:15250286283

悬停

导航 幻灯片和轮播图 对话框和灯箱 弹出层 滚动 延迟加载 悬停 Tabs logo设计 banner设计 文字设计 图标设计 办公软件教程

js鼠标悬停在图片上显示文字提示效果

发布日期:2016-03-01 浏览次数:2750

js鼠标悬停在图片上显示文字提示效果

鼠标悬停,文字提示

本文章来给大家推荐一款不错的js鼠标悬停在图片上显示文字提示效果,在很多网站可看到像网易相册就有这js鼠标悬停效果哦。

<!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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>面向对象</title>

<style type="text/css">

<!--

body {font-size: 14px;line-height: 24px;margin: 0px;padding: 0px;}

ul,li{margin:0px;padding:0px;list-style-type:none;}

img{border:0px;}

h3,p{margin:0px;padding:0px;}

h3{margin-top:50px;}

#show{width:724px;height:364px;border:#ccc 1px solid;margin:10px;overflow: hidden;}

li{float:left;margin-top:1px;margin-left:1px;height:180px;width:240px;overflow: hidden;}

#show .alt{position: absolute;background:#000;display:none;text-align:center;}

a,a:hover{color: #FFFFFF;text-decoration: none;}

-->

</style>

<script type="text/javascript">

function $(id){return typeof id === "string" ? document.getElementById(id) : id;}

function $$(oParent, elem){return (oParent || document).getElementsByTagName(elem);}

function imgLight(id)

{

    this.oDiv=$(id); 

 this.oImg=$$(oDiv,"img");  

 this.oLi=$$(oDiv,"li"); 

 this.oView=function(Obj)

 {

     var iMain=Obj;

  var iSpeed=1;

        var timer=null;

  iMain.onmouseout=function(){oClose(this);}

        timer=setInterval(function(){

      iMain.style.filter='alpha(opacity='+iSpeed+')';

            iMain.style.opacity=iSpeed/100;

      iSpeed+=1;

      if(iSpeed>=60){clearInterval(timer);}

   },1); 

 }

 this.oClose=function(Obj)

 {

     var oMain=Obj;

  var oSpeed=60;

  var otimer=null;

        otimer=setInterval(function(){

      oMain.style.filter='alpha(opacity='+oSpeed+')';

            oMain.style.opacity=oSpeed/100;

      oSpeed-=1;

      if(oSpeed<=0){clearInterval(otimer);oMain.style.display="none";};

   },1); 

 }

 for(var i=0;i<oLi.length;i++)

 {

     var oThis=oLi[i];

     oThis.onmouseover=function()

  {

      var oWidth=$$(this,"img")[0].offsetWidth;

      var oHeight=$$(this,"img")[0].offsetHeight;

      this.firstChild.style.width=oWidth+"px";

   this.firstChild.style.height=oHeight+"px";

      this.firstChild.style.display="block";

   oView(this.firstChild);

  }

  oThis.onclick=function()

  {

      window.location=$$(this.firstChild,"a")[0].href;

  }

 }

}


window.onload=function()

{

    var newImg=imgLight("show");

}

</script>

</head>

<body>

<div id="show">

  <ul>

    <li><div class="alt"><a href=""><h3>第一幅</h3><p>好久不见的向日葵</p></a></div><img  src="http://filesimg.111cn.net/2013/07/11/20130711074832708.jpg" width="240" height="180" /></li>

    <li><div class="alt"><a href=""><h3>第二幅</h3><p>纯手工雕刻的哦</p></a></div><img  src="http://filesimg.111cn.net/2013/07/11/20130711074839726.jpg" width="240" height="180" /></li>

 <li><div class="alt"><a href=""><h3>第三幅</h3><p>小桥流水人家</p></a></div><img  src="http://filesimg.111cn.net/2013/07/11/20130711074845255.jpg" width="240" height="180" /></li>

 <li><div class="alt"><a href=""><h3>第四幅</h3><p>又一幅小桥流水人家</p></a></div><img  src="http://filesimg.111cn.net/2013/07/11/20130711074851307.jpg" width="240" height="180" /></li>

 <li><div class="alt"><a href=""><h3>第五幅</h3><p>游民咖啡店</p></a></div><img  src="http://filesimg.111cn.net/2013/07/11/20130711074857962.jpg" width="240" height="180" /></li>

 <li><div class="alt"><a href=""><h3>第六幅</h3><p>动物世界</p></a></div><img  src="http://filesimg.111cn.net/2013/07/11/20130711074904754.jpg" width="240" height="180" /></li>

  </ul>

</div>

</body>

</html></td>

 </tr>

</table>


标签:全部
网友评论

湖南省长沙市网友3年前

111111

美国网友
X亿搜云全网营销平台

截屏,微信识别二维码

微信号:13913253836

(点击微信号复制,添加好友)

  打开微信

微信号已复制,请打开微信添加咨询详情!