Skip to content

Commit 66b779b

Browse files
committed
新增demo
1 parent 6f22d13 commit 66b779b

24 files changed

Lines changed: 656 additions & 0 deletions

File tree

‎js轮播图/css/style.css‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ul,li {
2+
list-style: none;
3+
margin: 0px;
4+
padding: 0px;
5+
}
6+
#wrap {
7+
width: 400px;
8+
height: 225px;
9+
margin: 0 auto;
10+
position: relative;
11+
overflow: hidden;
12+
}
13+
li {
14+
float: left;
15+
}
16+
#tips li {
17+
margin: 5px;
18+
border: 1px solid #f60;
19+
width: 20px;
20+
height: 20px;
21+
line-height:20px;
22+
text-align: center;
23+
color: white;
24+
cursor: pointer;
25+
}
26+
.active {
27+
background: #f60;
28+
}
29+
img {
30+
vertical-align: top;
31+
width:400px;
32+
}
33+
#content {
34+
width: 2400px;
35+
position: absolute;
36+
left: -1200px;
37+
}
38+
#content li {
39+
float: left;
40+
}
41+
#tips {
42+
position: absolute;
43+
right: 20px;
44+
bottom: 5px;
45+
}

‎js轮播图/images/1.jpg‎

54.2 KB
Loading

‎js轮播图/images/2.jpg‎

45.8 KB
Loading

‎js轮播图/images/3.jpg‎

26.7 KB
Loading

‎js轮播图/images/4.jpg‎

46.6 KB
Loading

‎js轮播图/images/5.jpg‎

54.3 KB
Loading

‎js轮播图/images/6.jpg‎

59.6 KB
Loading

‎js轮播图/index.html‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>轮播图</title>
6+
<link rel="stylesheet" href="css/style.css">
7+
8+
9+
</head>
10+
<body>
11+
<div id="wrap">
12+
<ul id="content">
13+
<li><img src="images/1.jpg" alt=""></li>
14+
<li><img src="images/2.jpg" alt=""></li>
15+
<li><img src="images/3.jpg" alt=""></li>
16+
<li><img src="images/4.jpg" alt=""></li>
17+
<li><img src="images/5.jpg" alt=""></li>
18+
<li><img src="images/6.jpg" alt=""></li>
19+
</ul>
20+
<ul id="tips">
21+
<li>1</li>
22+
<li>2</li>
23+
<li>3</li>
24+
<li>4</li>
25+
<li>5</li>
26+
<li>6</li>
27+
</ul>
28+
</div>
29+
<script src="js/move.js"></script>
30+
<script>
31+
var wrap=document.getElementById('wrap');
32+
var content=document.getElementById('content');
33+
var tips=document.getElementById('tips');
34+
var aLi=tips.getElementsByTagName('li');
35+
var now=0;
36+
for(var i=0;i<aLi.length;i++)
37+
{
38+
aLi[0].className="active";
39+
content.style.left=0+"px";
40+
aLi[i].onclick=function() {
41+
now=this.index;
42+
play();
43+
}
44+
}
45+
function play() {
46+
for(var j=0;j<aLi.length;j++)
47+
{
48+
aLi[j].className="";
49+
}
50+
aLi[now].className="active";
51+
startMove(content,{left: -400 * now,});
52+
}
53+
function autoPlay() {
54+
now++;
55+
if(now==aLi.length)
56+
{
57+
now=0;
58+
}
59+
play();
60+
}
61+
var timer=setInterval(autoPlay,2000);
62+
wrap.onmouseover= function () {
63+
clearInterval(timer);
64+
}
65+
wrap.onmouseout=function() {
66+
timer=setInterval(autoPlay,2000);
67+
}
68+
</script>
69+
</body>
70+
</html>

‎js轮播图/js/move.js‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function getStyle(obj,name){
2+
if(obj.currentStyle){
3+
return obj.currentStyle[name];
4+
}
5+
else{
6+
return getComputedStyle(obj,false)[name];
7+
}
8+
}
9+
function startMove(obj,json,fnEnd) {
10+
clearInterval(obj.timer);
11+
obj.timer=setInterval(function(){
12+
var bStop=true;
13+
for(var attr in json){
14+
var cur=0;
15+
if(attr=="opacity"){
16+
cur=Math.round(parseFloat(getStyle(obj,attr))*100);
17+
}
18+
else {
19+
cur=parseInt(getStyle(obj,attr))
20+
}
21+
var speed=(json[attr]-cur)/10;
22+
speed=speed>0?Math.ceil(speed):Math.floor(speed);
23+
if(cur!==json[attr])
24+
{
25+
bStop=false;
26+
};
27+
if(attr=="opacity")
28+
{
29+
obj.style.opacity=(speed+cur)/100;
30+
obj.style.filter='alpha(opacity:'+(speed+cur)+')';
31+
}
32+
else {
33+
obj.style[attr]=cur+speed+"px";
34+
}
35+
}
36+
if (bStop)
37+
{
38+
clearInterval(obj.timer);
39+
if (fnEnd) fnEnd();
40+
}
41+
},30)
42+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
<link rel="stylesheet" href="style.css">
7+
<script src="main.js"></script>
8+
</head>
9+
<body>
10+
<dl>
11+
<dt><input type="checkbox" id="checkAll"><label>全选</label><a href="javascript:;">反选</a></dt>
12+
<dd>
13+
<p><label><input type="checkbox" name="item" />选项(1)</label></p>
14+
<p><label><input type="checkbox" name="item" />选项(2)</label></p>
15+
<p><label><input type="checkbox" name="item" />选项(3)</label></p>
16+
<p><label><input type="checkbox" name="item" />选项(4)</label></p>
17+
<p><label><input type="checkbox" name="item" />选项(5)</label></p>
18+
<p><label><input type="checkbox" name="item" />选项(6)</label></p>
19+
<p><label><input type="checkbox" name="item" />选项(7)</label></p>
20+
<p><label><input type="checkbox" name="item" />选项(8)</label></p>
21+
</dd>
22+
</dl>
23+
</body>
24+
</html>

0 commit comments

Comments
 (0)