导航

萌即是正义!时不时分享一些ACG活动记录与有趣代码的小站!

【jQuery】文字轮流滚动播放

作者:广树·时间:2016-02-12 21:08:37·分类:JavaScript/jQuery/Vue

CSS部分:

#mobile4{width:auto;height:60px;overflow:hidden;cursor: pointer;font-size:12px!important;}
#mobile4 a{color:#000;}
#mobile4 .wtleft{ width:75px;float:left;}
#mobile4 .wtname{width:100%;float:left; margin-top:8px; height:20px;}
#mobile4 .order{width:100%;float:left; margin-top:3px; height:20px;}
#mobile4 .wt{width:112px;float:left;margin-top:5px }
#mobile4 .wtpic{line-height:48px;height:48px;width:48px;float:left;}
#mobile4 .wt1{width:64px; float:left;}
#mobile4 .wtline{width:100%;float:left; height:18px; line-height:18px;margin-top:3px;}
.mobile04{width:100%;font-size:12px;height:24px;overflow:hidden;}
.mobile04 ul{list-style-type:none;margin:0;padding:0;}
.mobile04 ul li{height:25px;line-height:25px;float:left;display:inline;width:100%; overflow:hidden;}
.mobile04 .f1{ background:#54A932; color:#fff; line-height:12px; padding:1px 2px 2px;}
.mobile04 ul li span{padding-left:5px;}



html部分:


<div class="mobile04" id="myscroll">
  <ul>
    <li>
            <span>2015-07-02</span> 
            <span>温州</span> 
            <span class="img04">
            <img class='pngtqico' align='absmiddle' src='http://img.tianqi.com/static/images/tianqi/b0.png' style='border:0;width:20px;height:20px'/>
            </span> 
            <span style="padding-left:0px;">晴</span> 
            <font style="color:#4899be;">12℃</font>~
            <font style="color:#f00;">4℃</font>      
    </li>
    <li>
            <span>2015-07-02</span> 
            <span>温州</span> 
            <span class="img04">
            <img class='pngtqico' align='absmiddle' src='http://img.tianqi.com/static/images/tianqi/b0.png' style='border:0;width:20px;height:20px'/>
            </span> 
            <span style="padding-left:0px;" id="tenki">晴</span> 
            <font style="color:#4899be;">22℃</font>~
            <font style="color:#f00;">4℃</font>      
    </li>
    <li>
            <span>2015-07-02</span> 
            <span>温州</span> 
            <span class="img04">
            <img class='pngtqico' align='absmiddle' src='http://img.tianqi.com/static/images/tianqi/b0.png' style='border:0;width:20px;height:20px'/>
            </span> 
            <span style="padding-left:0px;" id="tenki">晴</span> 
            <font style="color:#4899be;">32℃</font>~
            <font style="color:#f00;">4℃</font>      
    </li>
    <li>
            <span>2015-07-02</span> 
            <span>温州</span> 
            <span class="img04">
            <img class='pngtqico' align='absmiddle' src='http://img.tianqi.com/static/images/tianqi/b0.png' style='border:0;width:20px;height:20px'/>
            </span> 
            <span style="padding-left:0px;" id="tenki">晴</span> 
            <font style="color:#4899be;">42℃</font>~
            <font style="color:#f00;">4℃</font>      
    </li>
    <li>
            <span>2015-07-02</span> 
            <span>温州</span> 
            <span class="img04">
            <img class='pngtqico' align='absmiddle' src='http://img.tianqi.com/static/images/tianqi/b0.png' style='border:0;width:20px;height:20px'/>
            </span> 
            <span style="padding-left:0px;" id="tenki">晴</span> 
            <font style="color:#4899be;">12℃</font>~
            <font style="color:#f00;">4℃</font>      
    </li>
 </ul>
</div>



js部分:


<script type="text/javascript">
function AutoScroll(obj){
        $(obj).find("ul:first").animate({
                marginTop:"-25px"/*根据一条的实际高度*/
        },500,function(){
                $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
        });
}
$(document).ready(function(){
	li_num = $('#myscroll ul li').length
	tenki_speed = 2000 //滚动速度
	if(li_num > 1){
setInterval('AutoScroll("#myscroll")',tenki_speed)
	}
});
</script>
侧边栏
最新评论
广树
2024-05-08
@Asuna:谢谢!谢谢!
Asuna
2024-05-08
恭喜获得高质量博客认证~
广树
2024-05-08
@老张博客:是的,不仅仅是大城市,很多小乡村也是依靠动漫发展起来的旅游产业,所以不要小看文化产业带来的经济价值啊!
老张博客
2024-05-08
到日本 是不是大街小巷都是这些动漫呀!
广树
2024-05-08
@Chise Hachiroku:不是还有,而是最近出来的新服务🤭。送货时间太迟了,不是急需的话还是一般配送比较好。
正在攻略

圣兽之王.jpg

传颂之物

PSN奖杯卡

PSN奖杯卡

赞助商广告