zoukankan      html  css  js  c++  java
  • javaScript滚动新闻

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>滚动新闻</title>
    </head>
    <style type="text/css">
    	#div1{
    		200px;
    		height:80px; 
    		background-color:#CCC; 
    		position:absolute; 
    		left:0px; 
    		top:0px; 
    		z-index:1;
    		overflow:hidden;
    	}
    	#imgs{
    		100px; 
    		height:400px; 
    		background-color:#9C9; 
    		position:absolute; 
    		left:200px; 
    		top:0px; 
    		z-index:1;			//垂直方向置于最顶层
    		overflow:hidden;	//超出部分隐藏
    	}
    </style>
    <body>
    	<!--div 的高度设置比实际须要的高度小-->
    	<div id="div1">
        	<ul id="news">
        		<li><a href="#">aaaaaaaaaaaaaaa</a></li>
            	<li><a href="#">bbbbbbbbbbbbbbb</a></li>
            	<li><a href="#">ccccccccccccccc</a></li>
            	<li><a href="#">ddddddddddddddd</a></li>
            	<li><a href="#">eeeeeeeeeeeeeee</a></li>
            	<li><a href="#">fffffffffffffff</a></li>
            	<li><a href="#">ggggggggggggggg</a></li>
            </ul>
        </div>
        <div id="imgs">
        	<img src="imgs/11.png"></img>
            <img src="imgs/22.png"></img>
            <img src="imgs/33.png"></img>
            <img src="imgs/44.png"></img>
            <img src="imgs/55.png"></img>
        </div>
    </body>
    </html>
    <script type="text/javascript" language="javascript">
    		//注意须要让当前的dom载入全然之后,再运行js代码
    		//文字滚动
    		news = document.getElementById('news');
    		function newScroll(node){
    			var t = node.firstChild;
    			node.removeChild(t);
    			node.appendChild(t);
    		}
    		id = setInterval('newScroll(news)',400);
    		news.onmouseover = function(){
    			clearTimeout(id);
    		}
    		news.onmouseout = function(){
    			id = window.setInterval('newScroll(news)',400);
    		}
    		
    		//图片滚动
    		imgs = document.getElementById('imgs');
    		id1 = setInterval('newScroll(imgs)',400);
    		imgs.onmouseover = function(){
    			clearTimeout(id1);
    		}
    		imgs.onmouseout = function(){
    			id1 = window.setInterval('newScroll(imgs)',400);
    		}
    </script>

  • 相关阅读:
    day02_1spring3
    day01_2spring3
    动态代理的介绍
    day04_1hibernate
    day03_2hibernate
    Oracle11gR2安装完成后不手动配置监听的使用方法
    css的样式和选择符的优先权
    调用css时,link和@import url的区别
    jquery 获取和修改img标签的src属性
    正则表达式实现6-10位密码由数字和字母混合组成
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/3950022.html
Copyright © 2011-2022 走看看