滑动选项卡:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="../jQuery/jQuery.min.js"></script>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
ul {
list-style: none;
display: flex;
position: relative;
}
ul li {
height: 50px;
line-height: 50px;
text-align: center;
width: 100px;
position: relative;
z-index: 1;
}
ul div {
position: absolute;
width: 100px;
height: 50px;
top: 0;
left: 0;
background-color: aqua;
border-bottom: 3px solid red;
}
</style>
</head>
<body>
<ul>
<li>111</li>
<li>111</li>
<li>111</li>
<li>111</li>
<li>111</li>
<li>111</li>
<div></div>
</ul>
</body>
<script>
$("ul li").mouseover(function () {
console.log($(this).index());
var index = $(this).index();
$("ul div")
.stop()
.animate(
{
left: index * 100,
},
200
);
});
</script>
</html>
手风琴效果:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="../jQuery/jQuery.min.js"></script>
</head>
<style>
* {
padding: 0;
margin: 0;
}
ul {
width: 640px;
height: 300px;
margin: 100px;
display: flex;
border: 5px solid skyblue;
}
li {
width: 160px;
height: 300px;
overflow: hidden;
}
li img {
height