|
html
- <li><a href="/" target="_blank"
- title="标题文字1">标题文字1</a></li>
- <li><a href="/" target="_blank"
- title="标题文字122">标题文字122</a></li>
- <li><a href="/" target="_blank"
- title="标题文字133">标题文字133</a></li>
复制代码
js
- window.addEventListener('load', function() {
- var ul = document.querySelector('.infoList');
- var lis = ul.querySelectorAll('li');
- var liHeight = lis[0].offsetHeight;
- var index = 0;
- var timer;
- function animate() {
- index++;
- ul.style.transform = 'translateY(-' + index * liHeight + 'px)';
- ul.style.transition = 'transform 0.5s';
- }
- function reset() {
- index = 0;
- ul.style.transform = 'translateY(0)';
- ul.style.transition = 'none';
- }
- function startAnimation() {
- timer = setInterval(function() {
- animate();
- if (index >= lis.length - 1) {
- setTimeout(reset, 500);
- }
- }, 2000);
- }
- startAnimation();
- });
复制代码
|
上一篇:iis服务器上用伪静态web.config规则写网站301重定向的方法下一篇:VSCode出现下拉滚动后结尾出现一段距离修改方法
|