js实现消息滚动效果

2018-06-24 00:34:25来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

    <div class="inform" style="">
            <div style="height:35px; overflow:hidden;">
                <ul id="marquee" style="height:35px;">
            <li><a href="javascript:void(0)" style="display:inline-block;overflow: hidden; white-space: nowrap;text-overflow:ellipsis; width: 100%;">****已预订****</a></li>
             <li><a href="javascript:void(0)" style="display:inline-block;overflow: hidden; white-space: nowrap;text-overflow:ellipsis; width: 100%;">
                                ****已预订****</a></li>

          </ul> </div> <script type="text/javascript"> var liHeight = $('#marquee li').eq(0).outerHeight(); //$('#marquee').css('height',liHeight * $('#marquee li').length * 2); setTimeout("startmarquee("+ liHeight +", 50, 500, 'marquee')", 500); function startmarquee(lh,speed,delay,id) { var t; var p = false; var o = document.getElementById(id); o.innerHTML += o.innerHTML; o.onmouseover = function() { p = true; } o.onmouseout = function() { p = false; } o.scrollTop = 0; function start() { t = setInterval(scrolling,speed); if(!p) o.scrollTop += 1; } function scrolling() { if(o.scrollTop%lh != 0) { o.scrollTop += 1; if(o.scrollTop >= o.scrollHeight / 2) o.scrollTop = 0; } else { clearInterval(t); setTimeout(start,delay); } } setTimeout(start,delay); } </script> </div>

css:

.inform {
    padding: 1px;
    margin: 10px auto;
    /*position: fixed; bottom:80px;left: 50%;*/ width: 6.8rem;font-size: 12px;/*margin-left: -3.4rem;*/ border: none; background-color:rgba(238,115,115,0.3); border-radius: 10px;
}
.inform h2 {
    background: none repeat scroll 0 0 #015198;
    font-weight: normal;
    line-height: 30px;
}
.inform h2 span {
    color: #FFFFFF;
    font-size: 16px;
    padding-left: 10px;
}
.inform h2 a {
    color: #FFFFFF;
    float: right;
    font-size: 14px;
    padding-right: 3px;
}
.inform ul {
    height: 170px;
    margin-top: 7px;
    overflow: hidden;
}
.inform ul li {
    line-height: 26px;
    padding-left: 12px;
}

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Iframe父子窗口之间的跨域事件调用和传值

下一篇:搭建 Nodejs 生产环境