<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
margin: 0;
padding: 0;
} ul {
list-style: none;
} #banber {
border: #e74c3c 1px solid;
margin: 100px;
width: 800px;
height: 480px;
position: relative;
overflow: hidden;
} #banber span:last-child {
left: 780px;
} #banber span {
background: #999999;
font-size: 26px;
color: #ffffff;
width: 20px;
height: 40px;
opacity: 0.7;
position: absolute;
top: 220px;
} #banber ul {
width: 6000px;
position: absolute;
} #banber ul li {
width: 800px;
height: 480px;
float: left;
} #list {
position: absolute;
background-color: #cccccc;
left: 580px;
top: 420px;
height: 10px;
opacity: 0.7;
padding: 2px 50px 2px 0px; } #list a {
float: left;
background-color: #f23d9c;
border-radius: 50%;
width: 10px;
height: 10px;
margin-left: 8px;
} </style>
<script src="animte.js"></script> </head>
<body> <div id="banber">
<ul>
<li><img src="data:images/CJD2.jpg" alt=""></li>
<li><img src="data:images/CJD1.jpg" alt=""></li>
<li><img src="data:images/CJD3.jpg" alt=""></li>
<li><img src="data:images/CJD4.jpg" alt=""></li>
<li><img src="data:images/CJD5.jpg" alt=""></li>
</ul>
<div id="arrol">
<span><</span>
<span>> </span>
</div> <div id="list"> </div>
</div>
<script>
const banaer = document.getElementById('banber')
const arrol = document.getElementById('arrol')
const list = document.getElementById('list')
let index = 0
//1,动态生成小圆球
//获取ul
const b_ul = banaer.getElementsByTagName('ul')[0];
//获取LI的长度
const len = b_ul.getElementsByTagName('li').length
for (let i = 0; i < len; i++) {
let a = document.createElement('a')
list.appendChild(a)
a.onclick = Click
//设置标签自定义属性--很重要 添加索引
a.setAttribute('index', i)
}
list.children[0].style.backgroundColor = '#ff8400'
//点击
function Click() {
for (let i = 0; i < list.children.length; i++) {
let a = list.children[i]
a.style.backgroundColor = ''
this.style.backgroundColor = '#ff8400'
// 获取自定义属性 点的是第几个
index = parseInt(this.getAttribute('index'))
//调用动画
animte(b_ul, (-index) * 800)
}
} //箭头
arrol.children[0].onclick = function () { if (index == 0) {
index = len;
b_ul.style.left = -index * 800 + 'px';
}
index--;
list.children[index].click()
}
//无缝滚动
let firstLi = b_ul.children[0]
let clone = firstLi.cloneNode(true)
b_ul.appendChild(clone) arrol.children[1].onclick = function () {
if (index === len) {
b_ul.style.left = '0px';
index = 0
}
index++;
if (index < len) {
list.children[index].click()
} else {
animte(b_ul, index * -800)
for (let i = 0; i < list.children.length; i++) {
let a = list.children[i]
a.style.backgroundColor = ''
}
list.children[0].style.backgroundColor = '#ff8400'
}
}
// 自动播放
let time=setInterval(function () {
arrol.children[1].click()
},3000) banaer.onmouseenter=function () {
clearInterval(time)
}
banaer.onmouseleave=function () {
time=setInterval(function () {
arrol.children[1].click()
},3000)
} </script> </body>
</html>

  今天写了无缝轮播滚动 虽然代码有许许多多的不规范,不过对思维的一个锻炼 前面知识的复习,对于初学者也是很不错

最新文章

  1. Openfire阶段实践总结
  2. call,apply,bind的用法
  3. T-SQL Recipes之Index Defragmentation
  4. HTML 表格垂直对齐方式
  5. tesseract3.02识别验证码需要注意的问题
  6. 024-ActionResult解说
  7. C++ Primer 随笔 Chapter 9 顺序容器
  8. mysql如何删除重复记录
  9. centos 修改/etc/fstab后无法启动
  10. 我的学习之路_第三十章_servlet
  11. 《剑指offer》和为S的连续正数序列
  12. APPium-Xpath,swipe练习
  13. pdf阅读器开发
  14. SPOJ MKTHNUM &amp; POJ 2104 - K-th Number - [主席树模板题]
  15. win10下zip安装mysql5.7的一些问题
  16. Oracle中NVARCHAR2与VARCHAR2的相互转换
  17. 为 Tomcat 安装 apr
  18. PHP使用static关键字声明静态属性和静态方法
  19. SOAP消息的结构
  20. java 利用反射完成自定义注解

热门文章

  1. IDEA启动Tomcat报错Address localhost:1099 is already in use解决办法
  2. 解决对路径bin\roslyn..的访问被拒绝
  3. UVA 10564 计数DP
  4. 16 协程和www
  5. 五、React事件方法(自写一个方法(函数),然后用按钮onClick触发它、自写方法改变this指向3种写法、
  6. 使用FragmentStatePagerAdapter时发现的内存泄露问题
  7. BGP(IBGP“内部路由器”和EBGP“外部路由器”)命令解析
  8. jQuery搜索框输入实时进行查询
  9. stm32h7 hal 库的学习
  10. 关于GAN的一些笔记