惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
腾讯CDC
宝玉的分享
宝玉的分享
量子位
Recent Announcements
Recent Announcements
Martin Fowler
Martin Fowler
J
Java Code Geeks
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
S
SegmentFault 最新的问题
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
小众软件
小众软件
The Cloudflare Blog
Y
Y Combinator Blog
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
IT之家
IT之家

博客园 - RockyYu

策略模式 unity中的WWW通讯问题 需求分析的方法 用TlbImp.exe生成程序可调用的Dll C++程序引用Dll 查询本地注册表,调用某后缀文件相应的执行程序,并打开文件 windows服务的安装和卸载 FFmpeg和GPL协议 List<T>的排序 C#POST数据,HttpWebRequest请求页面,HttpWebResponse返回数据 XMLHttpRequest的使用方法 错误: 无法生成临时类 图片滚动效果代码 - RockyYu - 博客园 截取中文字符串的js方法 js调用XML数据生成DIV 迭代器模式(Iterator Pattern) 创建CLR存储过程 JavaScript Boolean (逻辑)对象 - RockyYu JavaScript文件只在IE6下出错(“未结束的字符串常量”)的解决办法。
一个不错的给图片添加说明文字的动态层的代码 - RockyYu - 博...
RockyYu · 2009-09-26 · via 博客园 - RockyYu

一个不错的给图片添加说明文字的动态层的代码

Posted on 2009-09-26 20:18  RockyYu  阅读(1499)  评论()    收藏  举报

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>代码运行_层移动</title>
<script language="javascript">
//运行代码
function runEx(cod1) {
cod=document.getElementById(cod1)
   var code=cod.value;
   if (code!=""){
    var newwin=window.open('','','');
    newwin.opener = null
    newwin.document.write(code);
    newwin.document.close();
}
}
//复制代码
function doCopy(ID) {
if (document.all){
   textRange = document.getElementById(ID).createTextRange();
   textRange.execCommand("Copy");
}
else{
   alert("此功能只能在IE上有效")
}
}
</script>
</head>
 
<body>
<textarea rows="8" cols="65" id="CodeText10248" class="UBBText">
<!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=utf-8" />
<title>滑动说明文字</title>
<style type="text/css" media="all">
.slide_bg{border:#999999 3px solid;width:207px;height:106px;position:relative;overflow:hidden;float:left;margin-right:16px;margin-top:26px;}
.slide_img{background-image:url(/jscss/demoimg/wall1.jpg);width:207px;height:106px;}
.slide_txt{width:197px;height:100px;background-color:#000000;position:absolute;top:106px;left:0px;color:#FFCC33;line-height:22px;padding:5px;font-size:12px;}
</style>
<script language="javascript" type="text/javascript">
var slide_content=function(){
   var id="slide_content"  //滑动图片父容器的id名
   var interval=10;    //滑动速度
   var interval2=100;  //文字滑出延迟时间(毫秒)
   var interval3=500;  //文字内容自动消失的延迟时间(毫秒)
   var opacity=69;     //文字内容图层透明度
   var timer2=new Array();
   var elem=new Array();
   var status=new Array();
   var div=document.getElementById(id).getElementsByTagName("div");
   var timer3=0;   
   //run_animation
    var d=function(){
var timer,obj,txt;var ypos=100;
      this.run=function(pra1,pra2,dir){obj=pra1;txt=pra2;if(dir>0){clearTimeout(timer);clearTimeout(timer3);timer3=setTimeout(obj.up,interval2);}else{clearTimeout(timer);obj.down()};txt.style.filter="alpha(opacity="+opacity+")";txt.style.opacity=opacity/100;}
//向上滑动
      this.up=function(){if(ypos<=0){txt.style.top="0px"}else{ypos-=10;txt.style.top=ypos+"px";timer=setTimeout(obj.up,interval)}}
//向下滑动
      this.down=function(){if(ypos>=106){txt.style.top="106px";}else{ypos+=15;txt.style.top=ypos+"px";timer=setTimeout(obj.down,interval)}}
    }
 //init mouse_behavior
 for(var i=0;i<div.length;i+=3){
     div[i+1].index=div[i+2].index=i+2;
  elem[i+2]=new d();
  div[i+1].onmouseover=function(){elem[this.index].run(elem[this.index],div[this.index],1)};
  div[i+1].onmouseout=function(){var n=this.index;if(status[n]!=1){timer2[n]=setTimeout(imgout,interval3)};function imgout(){elem[n].run(elem[n],div[n],-1)}}     
  div[i+2].onmouseout=function(){elem[this.index].run(elem[this.index],div[this.index],-1);status[this.index]=0}
     div[i+2].onmouseover=function(){clearTimeout(timer2[this.index]);status[this.index]=1}
 }
}
//网页加载完毕时,启动函数
window.onload=slide_content;
</script>
</head>
<body>
<div id="slide_content">
  <div class="slide_bg">
    <div class="slide_img"></div>
    <div class="slide_txt">春天:<br />春天是播种的季节。</div>
  </div>
  <div class="slide_bg">
    <div class="slide_img"></div>
    <div class="slide_txt">夏天:<br />夏天是火热的季节。</div>
  </div>
  <div class="slide_bg">
    <div class="slide_img"></div>
    <div class="slide_txt">秋天:<br />秋天是丰收的季节。</div>
  </div>
  <div class="slide_bg">
    <div class="slide_img"></div>
    <div class="slide_txt">冬天:<br />冬天是雷人的季节。</div>
  </div>
</div>
</body>
</html></textarea><br/><input onclick="runEx('CodeText10248')" type="button" value="运行此代码"/> <input onclick="doCopy('CodeText10248')" type="button" value="复制此代码"/><br/>
</body>
</html>

                               --小小的,有大大的梦想!