您的位置:首页 > 其它

鼠标放到图片上会滑出提示文字

2016-07-11 11:27 218 查看
<!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>

<title>滑动提示</title>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<style>

*{margin:0;padding:0;font-size:12px}

ul,ol{list-style-type:none}

#show{background:white;height:180px;width:180px;position:relative;overflow:hidden;text-align:center}

#show h2{position:absolute;height:50px;text-align:center;line-height:50px;width:100%;opacity:0.5;background:black;color:white;left:0;bottom:0}

</style>

<script>

function go(){

var t,tt;

var _div=document.getElementById("show");

var obj=_div.getElementsByTagName('h2')[0];

obj.style.bottom="-50px";

var change=function(){

var obj_h=parseInt(obj.style.bottom);

if(obj_h<0){obj.style.bottom=(obj_h+Math.floor((0-obj_h)*0.1))+"px"}//if

else{clearInterval(t)}

}

var back=function(){

var obj_hh=parseInt(obj.style.bottom);

if(obj_hh>-50){obj.style.bottom=(obj_hh+Math.floor((-50-obj_hh)*0.1))+"px"}

else{clearInterval(tt)}

}

_div.onmouseover=function(){clearInterval(tt);t=setInterval(change,10);}

_div.onmouseout=function(){clearInterval(t);tt=setInterval(back,10)}

}

window.onload=function(){

go();

}

</script>

</head>

<body>

<div id="show">

<h2>北国南疆,风光无限</h2>

<img src="wall2.jpg" />

</div>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: