문자가 원활하게 스크롤 휠캐스트(주마등 효과)

1507 단어

문자 가로등 효과




    
    
    <script language="javascript" type="text/javascript">
       window.onload=function(){
       		var box =  document.getElementById('box');
            var divList = document.getElementById('divList');
            var copyDiv = document.getElementById('copyDiv');
            var copyDivW =copyDiv.clientWidth;
            var speed = 10;    // , 
			function marquee() {
                if (copyDiv.offsetLeft - box.scrollLeft <= 0){// box 
                	box.scrollLeft -= divList.offsetWidth-copyDivW    
                }else {
	                    box.scrollLeft++
	                }
	            }
            var timer = setInterval(marquee, speed);//         

       }
    </script>
    <style>
    	.news{
    		float: left;
    		width: 300px;
    	}
    </style>


<div id="box" style="overflow:hidden;height:22px;width:300px;border:1px solid #000;">
    <div id="divList" style="height: 21px;width: 9999px;">
        <div class="news"> </div>
        <div class="news"> </div>

        <!--   -->
        <div class="news" id="copyDiv"> </div>
    </div>

</div>


</code></pre> 
 </div> 
</div>
                            </div>
                        </div>

좋은 웹페이지 즐겨찾기