<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
#box {
width: 590px;
height: 340px;
border: #000 1px solid;
position: relative;
margin: 50px auto;
overflow: hidden;
}
#box li {
position: absolute;
width: 590px;
height: 340px;
}
</style>
<script src="move.js"></script>
<script>
window.onload = function () {
var oBox = document.getElementById('box');
var aLi = oBox.children;
var w = 40;
for (var i = 1; i < aLi.length; i++) {
aLi[i].style.left = oBox.offsetWidth - w * (aLi.length - i) + 'px';
}
for (var i = 0; i < aLi.length; i++) {
aLi[i].index = i;
aLi[i].onmouseover = function () {
for (var i = 0; i < aLi.length; i++) {
if (i <= this.index) {
move(aLi[i], {left: w * i});
} else {
move(aLi[i], {left: oBox.offsetWidth - w * (aLi.length - i)});
}
}
}
}
}
</script>
</head>
<body>
<ul id="box">
<li style="background: pink"></li>
<li style="background: green"></li>
<li style="background: yellow"></li>
<li style="background: red"></li>
<li style="background: blue"></li>
</ul>
</body>
</html>
相关文章
- js手风琴
- JS设计模式(11)中介者模式
- js用百度地图api写一个有标注点有连线有点击气泡的地图
- 高德地图 JS API【入门】—— 动态添加、删除覆盖物
- 使用Underscore.js的template将Backbone.js的js代码和html代码分离
- OCX制作CAB(三) -- INF文件的编写及WEB JS 调用OCX和CAB
- Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js)
- 进阶学习Node.js,你需要掌握什么基础?
- 获取iframe子页面js方法,子页面调用父页面变量
- chrome浏览器跳过(忽略)所有的js断点