-
Notifications
You must be signed in to change notification settings - Fork 0
/
原生JS-无缝滚动-1.html
65 lines (63 loc) · 1.6 KB
/
原生JS-无缝滚动-1.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>原生JS-无缝滚动-1</title>
<script type="text/javascript">
// 总共分了10份,准备给content 10份
setRem();
window.onresize = setRem;
function setRem() {
document.getElementsByTagName('html')[0].style.fontSize = document.documentElement.clientWidth / 10 + 'px';
}
</script>
<style>
*{
padding: 0;
margin: 0;
}
body{
background-color: coral;
}
#div1{
width: 10em;
height: 2.4rem;
margin: 0 auto;
position: relative;
background-color: cornflowerblue;
overflow: hidden;
}
#div1 ul{
position: absolute;
top:0;
left: 0;
}
#div1 ul li{
list-style: none;
float: left;
width: 2.93333rem;
height: 2rem;
background-color: aquamarine;
margin: 0.2rem;
}
#div1 ul li img{
/*width: auto;
height: auto;
max-width: 100%;
max-height: 100%;*/
width: 2.93333rem;
height: 2rem;
}
</style>
</head>
<body>
<div id="div1">
<ul>
<li><img src="img/1.jpg" alt=""/></li>
<li><img src="img/2.jpg" alt=""/></li>
<li><img src="img/3.jpg" alt=""/></li>
<li><img src="img/1.jpg" alt=""/></li>
</ul>
</div>
</body>
</html>