日期:2014-05-17  浏览次数:20623 次

网页滚动字幕
在网页设计中用marquee标签在一个宽为300高为300层里设置滚动字幕,但它的效果是一开始那片区域是没有东西的然后在慢慢滚动出现字幕的,我要找的效果是一开始是有东西的,只是层里的东西没有显示完,然后通过滚动把它显示完,并且循环开始滚动。菜鸟求高手解答,希望能附上代码解析!

------解决方案--------------------
楼主可以搜下 js文字左右滚动,
参考下
HTML code

<div id="dvvv" style="overflow: hidden; height: 27px; width: 750px;">
                                                    <div id="dvvv1">
                                                        <ul style="padding-left: 0px; margin-top: 0px;">
                                                            <li style="list-style-type: none;white-space:nowrap">
                                                               中文为什么就不行,中文为什么就不行中文为.什么就不行中文为什么就不行中文,为什么就不行中。文为什么。就不行中文为什么就不行中文为什。么就不行中文为什么就不行中文为什么就不行中文为什么就不行中文为什么就不行。中文为什么。就不行中文为什么就不行中文。为什么就不行中文为什么就不。行中文为什么就不行中。文为什么就不行中文为什么就。不行中文为什。么就不行中文为什么。就不行么就不行中文为什么就不行中文为什么就不行。中文为什么。就不行中文为什么就不行中文。为什么就不行中文为什么就不。行中文为什么就不行中。文为什么就不行中文为什么就。不行中文为什。么就不行中文为什么。就不行</li>。
                                                        </ul>
                                                    </div>
                                                    <div id="dvvv2">
                                                    </div>
                                                </div>

<script type="text/javascript">
             var speded=30
             dvvv2.innerHTML=dvvv1.innerHTML
             function Marqpuee(){
             if(dvvv2.offsetWidth-dvvv.scrollLeft<=0)
             dvvv.scrollLeft-=dvvv1.offsetWidth
             else{
             dvvv.scrollLeft++
             }
             }
             var MyMmar=setInterval(Marqpuee,speded)
             dvvv.onmouseover=function() {clearInterval(MyMmar)}
             dvvv.onmouseout=function() {MyMmar=setInterval(Marqpuee,speded)}
        </script>

------解决方案--------------------
lz 要的应该是无缝滚动代码,看看:

HTML code

<!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>竖向向无缝滚动</title>
    <style type="text/css">
        .sqBorder {width:300px; height:300px; padding:0px; background:#666666; overflow:hidden; border:solid 1px red; background:yellow;}
        .scroll_div {width:300px; height:300px; overflow: hidden;  background:yellow;} /* white-space: nowrap; 竖向不是滚动的重要条件*/
</style>
</head>
<body>

    <div class="sqBorder">
        <div id="scroll_div" class="scroll_div">
            <div id="scroll_begin">
                    <h4>start...</h4>
                    <h4>无缝滚动测试代码</h4><h4>无缝滚动测试代码</h4><h4>无缝滚动测试代码</h4><h4>无缝滚动测试代码</h4><h4>无缝滚动测试代码</h4><h4>无缝滚动测试代码</h4><h4>end...</h4>
            </div>
            <div id="scroll_end"></div>
        </div>
    </div>
<script type="text/javascript">
    function ScrollImgTop(speed,div,s_begin,s_end){
        var divObj = document.getElementById(div);
        var beginObj = document.getElementById(s_begin);
        var endObj = document.getElementById(s_end);
        
        endObj.innerHTML=beginObj.innerHTML;
        
        function Marquee(){
            if(endObj.offsetHeight-divObj.scrollTop<=0){
                divObj.scrollTop=0;  // 由于下面else设置为+=1,所以这里直接设置为0即可。
                
            }
            else{
                divObj.scrollTop+=1; 
            }
        }
        var