-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote.html
More file actions
162 lines (155 loc) · 5.45 KB
/
note.html
File metadata and controls
162 lines (155 loc) · 5.45 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>胸毛仙人</title>
<link rel="stylesheet" type="text/css" href="./css/note.css">
<link rel="stylesheet" type="text/css" href="./css/prism.css">
<link href="https://cdn.bootcss.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="./js/prism.js"></script>
</head>
<body class="main">
<div class="main-header">
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1><a href="#" title="" data-original-title="胸毛仙人"> 胸毛仙人个人笔记</a></h1>
<h2 class="h4">Happy Life, Happy Coding!</h2>
</div>
</div>
</div>
</div>
<nav class="main-navigation">
<div class="container">
<div class="row">
<div class="col-sm-12">
chensk.home@gmail.com
</div>
</div>
</div>
</nav>
<section class="content-wrap">
<div class="container">
<div class="row">
<main class="col-md-8 main-content ">
<div class="article">
<h2>js无缝滚动</h2>
<pre class="language-javascript" data-language="javascript">
<code class="language-javascript">
<div id="con">
<ul id="scroll1">
<li style="margin-top: -10px;">hello,world0</li>
<li >hello,world1</li>
<li >hello,world2</li>
<li >hello,world3</li>
<li >hello,world4</li>
<li >hello,world5</li>
<li >hello,world6</li>
<li >hello,world7</li>
<li >hello,world8</li>
<li >hello,world9</li>
</ul>
<ul id="scroll2" >
</ul>
</div>
//scrollTop 向上滚动数值
//offsetHeight 元素高度
//setInterval 按指定周期执行
//clearInterval 清除执行
var area = document.getElementById("con");
var scroll1 = document.getElementById('scroll1');
var scroll2 = document.getElementById('scroll2');
scroll2.innerHTML = scroll1.innerHTML;
function scrollUp(){
if(area.scrollTop >= scroll1.offsetHeight){
area.scrollTop = 0;
}else{
area.scrollTop++;
}
}
var time = 50;
var myScroll = setInterval('scrollUp()',time);
area.onmouseover = function(){
clearInterval(myScroll);
}
area.onmouseout = function(){
myScroll = setInterval('scrollUp()',time);
}
</code>
</pre>
</div>
<div class="article">
<h2>js 间歇性无缝滚动</h2>
<pre class="language-markup" data->
<code class="language-markup">
<div id="con">
<ul id="scroll1">
<li style="margin-top: -10px;">hello,world0</li>
<li >hello,world1</li>
<li >hello,world2</li>
<li >hello,world3</li>
<li >hello,world4</li>
<li >hello,world5</li>
<li >hello,world6</li>
<li >hello,world7</li>
<li >hello,world8</li>
<li >hello,world9</li>
</ul>
<ul id="scroll2" >
</ul>
</div>
//scrollTop 向上滚动数值
//offsetHeight 元素高度
//setInterval 按指定周期执行
//clearInterval 清除执行
var area = document.getElementById("con");
var iLiHeight = 20;
var time;
var speed = 50;
var delay = 2000;
area.innerHTML += area.innerHTML;
area.scrollTop = 0;
function startMove(){
area.scrollTop++;
time = setInterval('scrollUp()',speed);
}
function scrollUp(){
if (area.scrollTop % iLiHeight == 0) {
clearInterval(time);
setTimeout("startMove()",delay);
}else{
area.scrollTop++;
if (area.scrollTop >= area.scrollHeight/2) {
area.scrollTop=0;
}
}
}
setTimeout("startMove()",delay);
</code>
</pre>
</div>
</main>
<aside class="col-md-4 sidebar">
<div class="affix-top">
<aside id="search-2" class="widget widget_search clearfix">
<h4 class="title">微信二维码</h4>
<div class="textwidget"><div><img src="./images/csk.jpg"></div></div>
</aside>
</div>
</aside>
</div>
</div>
</section>
<div class="footer">
<div class="container footer-content">
<h4>学习资源网站:</h4>
<ul class="list-inline">
<li>
<a href="http://www.bootcss.com/">bootstrap中文网</a>
</li>
</ul>
</div>
</div>
</body>
</html>