展示大屏的常用效果[无线滚动]

1/向上面不间断无线滚动效果
css:

<div class="mesgBox marquee>我是需要滚动的内容</div>
/* 动画 */
@keyframes scroll-top {
    0%{}
    100%{
        transform: translateY(-50%);
    }
}
.marquee {
    animation: scroll-top 15s linear infinite;
}
 .marquee:hover{
    animation-play-state: paused;
}
// 滚动复制一份;如果内容少不足以滚动,就移除marquee
    $('.marquee').each(function () {
        // 拿到了marquee里面的所有row
       var rows = $(this).children().clone();
        // 追加进去
        $(this).append(rows);
        // 父.append(子)==>子.appendTo(父)
        // $('ul').append($('<li>li</li>'));==>$('<li>li</li>').appendTo('ul');
    });

2/一帧一帧向上无线滚动

<div class="maquee">
	<ul>
		<li>第一行</li>
		<li>第二行</li>
		<li>第三行</li>
		<li>第四行</li>
	</ul>
</div>
<style>
.maquee{width:100%;height:120px;overflow:hidden;}
.maquee li{height:38px;}
</style>

js:

 
	  function autoScroll(obj){  
			$(obj).find("ul").animate({  
				marginTop : "-39px"  //一个li子元素的行高
			},500,function(){  
				$(this).css({marginTop : "0px"}).find("li:first").appendTo(this);  
			})  
		}  
		$(function(){  
			setInterval('autoScroll(".maquee")',2000);
		}) 

3/无线滚动向上
html:

<div class="showMain" style="position: relative;width: 100%; height: 958px; overflow-y: auto">
 <div class="runDataBox innerbox" id="areaBox" style="height: 956px">
    <!--gm运行参数gm -->
    <div id="nowBox"><p>当前显示内容</p></div>
    <div id="nextBox"><p>复制当前显示内容到这里</p></div>
  </div>
</div>
<style>
.runDataBox {
  height: 715px;
  overflow-y: auto;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}

#nowBox {
  display: flex;
  flex-direction: column;
}
</style>

js:

      var speed1 = 20
      var box = document.getElementById('areaBox')//保证数字为0,父级添加position:relative;
      var box1 = document.getElementById('nowBox')
      var box2 = document.getElementById('nextBox')
      box2.innerHTML = box1.innerHTML
      // $('#box2').html(box1)
      function Marquee1() {
        if (box2.offsetTop - box.scrollTop <= 0) box.scrollTop -= box1.offsetHeight
        else {
          box.scrollTop++
        }
      }
      var MyMar1 = setInterval(Marquee1, speed1)
      box.onmouseover = function () {
        clearInterval(MyMar1)
      }
      box.onmouseout = function () {
        MyMar1 = setInterval(Marquee1, speed1)
      }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值