-
Notifications
You must be signed in to change notification settings - Fork 50
/
index3.html
68 lines (67 loc) · 2.54 KB
/
index3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>无缝不间断向上滚动</title>
<style type="text/css">
*{margin:0; padding: 0;}
ul{list-style: none;}
.nav{max-width: 800px; margin: 0 auto; padding:20px 0; display: flex; flex-flow:row wrap; justify-content:space-around; border-bottom: 1px solid #ddd;}
.nav a{font-size: 14px; color: #333; text-decoration: none;}
.nav a:hover, .nav .current{color: #f00; text-decoration: underline;}
.a{height: 400px; overflow: hidden; margin:10px auto; width: 200px;}
li{height: 198px; width: 198px; border:1px solid #ddd; line-height: 2.4; font-size: 30px; text-align: center;}
</style>
</head>
<body>
<div class="nav"><a href="https://qdkfweb.cn/">前端博客</a><a href="https://qdkfweb.cn/scrollForever" target="blank">插件使用介绍</a><a href="index.html">无缝滚动插件版</a><a href="index1.html">无缝向左1</a><a href="index2.html">无缝向左2</a><a href="index3.html" class="current">无缝向上</a><a href="index4.html">间断向左</a><a href="index5.html">间断向上</a></div>
<div class="a">
<ul id="marquee_1">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
<li>11</li>
<li>12</li>
</ul>
</div>
<script src="js/jquery.js"></script>
<script type="text/javascript">
jQuery.fn.extend({
pic_scroll:function (){
$(this).each(function(){
var _this=$(this);//存储对象
var ul=_this.find("ul");//获取ul对象
var li=ul.find("li");//获取所有图片所有的li
var w=li.size()*li.outerHeight();//统计图片的长度
li.clone().prependTo(ul);//克隆图片一份放入ul里
ul.width(2*w);//设置ul的长度,使所有图片排成一排
var i=1,l;
_this.hover(function(){i=0},function(){i=1});//鼠标经过时设置i=0达到鼠标经过停止效果
function autoScroll(){
l = _this.scrollTop();
if(l>=w){
_this.scrollTop(0);
}else{
_this.scrollTop(l + i);
}
}
var scrolling = setInterval(autoScroll,20);
})
}
});
$(function(){
// var time1 = new Date;
$(".a").pic_scroll();
// console.log("耗时:" + (new Date - time1) + " 毫秒");
})
</script>
<script type="text/javascript" src="https://qdkfweb.cn/demo/base.js" charset="UTF-8"></script>
</body>
</html>