图片、文字无缝滚动

  1. <!doctype html>   
  2. <title>javascript图片左右无缝滚动</title>   
  3. <meta charset="utf-8"/>   
  4. <meta name="keywords" content="javascript无缝滚动" />   
  5. <meta name="description" content="javascript无缝滚动" />   
  6. <!-- <base href="http://images.cnblogs.com/cnblogs_com/rubylouvre/199042/"> -->   
  7. <style type="text/css">   
  8.   h1 {   
  9.     font:400 16px/1 "Microsoft YaHei",KaiTi_GB2312,SimSun   
  10.   }  
  11.   #marquee {   
  12.     position:relative;   
  13.     width: 600px;   
  14.     height: 280px;   
  15.     overflow:hidden;   
  16.     border: 10px solid #8080C0;   
  17.   }  
  18.   #marquee img {   
  19.     border:0px;   
  20.   }  
  21.   #marquee dl, #marquee dt,#marquee dd,#marquee a {  
  22.     float:left;   
  23.     margin:0;   
  24.     padding:0;   
  25.   }  
  26.   #marquee dl{   
  27.     width:1000%;   
  28.     height:150px;   
  29.   }   
  30. </style>   
  31. <script type="text/javascript">   
  32.   var Marquee = function(id){   
  33.     try{document.execCommand("BackgroundImageCache"falsetrue);}catch(e){};   
  34.     var container = document.getElementById(id),   
  35.     original = container.getElementsByTagName("dt")[0],   
  36.     clone = container.getElementsByTagName("dd")[0],   
  37.     speed = arguments[1] || 10;   
  38.     clone.innerHTML=original.innerHTML;   
  39.     var rolling = function(){   
  40.       if(container.scrollLeft == clone.offsetLeft){   
  41.         container.scrollLeft = 0;   
  42.       }else{   
  43.         container.scrollLeft++;   
  44.       }   
  45.     }   
  46.     var timer = setInterval(rolling,speed)//设置定时器  
  47.     container.onmouseover=function() {clearInterval(timer)}//鼠标移到marquee上时,清除定时器,停止滚动  
  48.     container.onmouseout=function() {timer=setInterval(rolling,speed)}//鼠标移开时重设定时器  
  49.   }   
  50.   window.onload = function(){   
  51.     Marquee("marquee");   
  52.   }   
  53. </script>   
  54. <h1>javascript无缝滚动(向右滚动) </h1>   
  55. <div id="marquee">   
  56.   <dl>   
  57.     <dt>   
  58.       <a href=""><img src="images/1.jpg" alt="javascript无缝滚动"/></a>   
  59.       <a href=""><img src="images/2.jpg" alt="javascript无缝滚动"/></a>   
  60.       <a href=""><img src="images/3.jpg" alt="javascript无缝滚动"/></a>   
  61.       <a href=""><img src="images/4.jpg" alt="javascript无缝滚动"/></a>   
  62.     </dt>   
  63.     <dd></dd>   
  64.   </dl>   
  65. </div>  

http://www.nowamagic.net/javascript/javascript_PicSlider.php

http://www.nowamagic.net/javascript/

<!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>文字列表无缝向上滚动JavaScript代码</title>
<style>
*{margin:0px;padding:0px;border:0px;}
body{font-size:12px}
#demo1{
height:auto;
text-align:left;
}
#demo2{
height:auto;
text-align:left;
}
#demo1  li{
list-style-type:none;
height:22px;
background:url() no-repeat left center;
text-align:left;
text-indent:15px;
}
#demo2  li{
list-style-type:none;
height:22px;
background:url() no-repeat left center;
text-align:left;
text-indent:15px;
}
</style>
</head>
<body>
<div id="demo" style="overflow:hidden;height:80px;width:280px;">
<ul id="demo1"> 
<li>

<a href="/soft/4085.shtml" target="_blank">XP Menu 仿QQ菜单管理器左侧菜单</a></li>

<li><a href="/soft/5884.shtml" target="_blank">多层嵌套的一个层展开</a></li>

<li><a href="/soft/1852.shtml" target="_blank">《Java2核心技术卷2:高级特性》第7版</a></li>

<li><a href="/soft/1286.shtml" target="_blank">CSS、HTML教程打包下载 (CHM)</a></li>

<li><a href="/soft/4216.shtml" target="_blank">《C++ Primer》中文第四版 chm</a></li>

<li><a href="/soft/3388.shtml" target="_blank">C++工资管理系统(Access)</a></li>

<li><a href="/soft/2009.shtml" target="_blank">非常牛的左侧栏JS折叠菜单</a></li>
</ul>
<div id="demo2"></div>
</div>
<script>
var speed=40
var demo=document.getElementById("demo");
var demo2=document.getElementById("demo2");
var demo1=document.getElementById("demo1");
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetTop-demo.scrollTop<=0)
  demo.scrollTop-=demo1.offsetHeight
else{
  demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html>

http://www.codefans.net/jscss/code/1639.shtml

你可能感兴趣的:(JavaScript,html,timer,function,XHTML,border)