鼠标放到图片上会滑出提示文字,不用多介绍了,运行一下就知道效果了。
<!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="/jscss/demoimg/wall2.jpg" />
</div>
</body>
</html>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。