无缝轮播图(Jquery)
实现功能(无缝轮播图Jquery)
利用移动定位进行无缝滚动,大体实现点击切换图片,每张图片对应一个小圆点,并且小圆点点击可以进行切换。鼠标移入停止图片轮播
强调
jquery引入本地引入,你可以在网上导入
全局由index贯穿
动画中的回调函数
flag标识,进行判断动画在执行中还是执行结束
对于图片切换到第一张还是最后一张的处理
css代码片段
* {
padding: 0;
margin: 0;
}
html,
body {
height: 100%;
overflow: hidden;
}
body{
background: rgba(0, 0, 0, 0.2);
}
.box {
width: 1000px;
height: 80%;
margin: 50px auto;
position: relative;
overflow: hidden;
box-shadow: 2px 2px 15px #333333;
}
ul {
height: 100%;
position: absolute;
display: flex;
}
ol,
ul,
li {
list-style: none;
}
li {
flex-shrink: 0;
width: 1000px;
height: 100%;
}
li>img {
width: 100%;
height: 100%;
}
button {
width: 70px;
height:50px;
color: #f5f5f5;
position: absolute;
z-index: 3;
top: 50%;
transform: translateY(-50%);
background: rgba(0, 0, 0, 0.2);
border-radius:0 5px 5px 0;
opacity: 0;
border: none;
cursor: pointer;
outline: none;
transition: all 1s;
}
.box:hover button{
opacity: 1;
}
button:hover{
background: rgba(0, 0, 0, 0.5);
}
.left{
border-radius:0 5px 5px 0;
}
.right {
border-radius:5px 0px 0px 5px;
right: 0;
}
ol{
width: 120px

这篇博客详细介绍了如何利用Jquery实现无缝轮播图的功能,包括点击切换图片、小圆点导航以及鼠标悬停停止轮播的效果。文章提到了关键点如Jquery的引入、全局变量的使用、动画回调函数、状态标识以及处理图片首尾切换的策略。
最低0.47元/天 解锁文章
8014

被折叠的 条评论
为什么被折叠?



