<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;padding: 0;
}
ul{
list-style: none;
}
#div1{
width: 100%;
overflow: hidden;
position: relative;
}
#div1 img{
width: 100%;

}
.ul1{
position: absolute;
top:40%;
width: 100%;
}
.ul1 li{
width: 25px;
height: 50px;
}
.ul1 li div{
border-top: 25px solid transparent;
border-bottom: 25px solid transparent;
}
.ul1 #prev{

float: left;
margin-left: 10%;
}
.ul1 #prev div{
border-right: 25px solid white;
}
.ul1 #next{

float: right;
margin-right: 10%;}
.ul1 #next div{
border-left: 25px solid white;
}
.ul2{
position: absolute;
bottom: 10px;
left: 40%;
}
.ul2 li{
float: left;
width: 20px;
height: 20px;
border-radius: 10px;

margin-right: 10px;
}
.ul2 li.black{
background: rgba(86,86,86,0.8);
}
.ul2 li.orange{
background: rgba(248,114,6,0.8);
}
</style>
</head>
<body>
<div id="div1">
<img src="Images/banner_1.jpg" alt="" title="" id="img1" />
<ul class="ul1">
<li id="prev">
<div></div>
</li>
<li id="next">
<div></div>
</li>
</ul>
<ul class="ul2" id="page">

</ul>
</div>
<script>
var div1,imgs,prev,next,ul2,lis,index=0;

//存放图片
var arr=[{id:1,src:"Images/banner_1.jpg",title:"",href:""},

{id:2,src:"Images/banner_2.jpg",title:"",href:""},

{id:3,src:"Images/banner_3.jpg",title:"",href:""},

{id:4,src:"Images/banner_longtou.jpg",title:"",href:""}];
var timer=null;
window.onload=function(){
div1=document.getElementById("div1");
imgs=div1.getElementsByTagName("img")[0];
prev=document.getElementById("prev");
next=document.getElementById("next");
ul2=document.getElementById("page");

//创建小点元素

for(var i=0,len=arr.length;i<len;i++){
var li=document.createElement("li");
li.className="black";
li.value=i;
li.onclick=liClick;
ul2.appendChild(li);
}
lis=ul2.getElementsByTagName("li");
lis[0].className="orange";
prev.onclick=prevCLick;
next.onclick=nextClick;
timer=setInterval(auto,3000);
}
//自动改变索引
function auto(){
index++;
if(index==arr.length){
index=0;
}
show();
}
//切换图片按钮颜色
function show(){
imgs.src=arr[index].src;
for(var i=0,len=lis.length;i<len;i++){
lis[i].className="black";
}
lis[index].className="orange";
}
function prevCLick(){
clearInterval(timer);
index--;
if(index<0){
index=arr.length-1;
}
show();
timer=setInterval(auto,3000);
}
function nextClick(){
clearInterval(timer);
index++;
if(index==arr.length){
index=0;

}
show();
timer=setInterval(auto,3000);
}
function liClick(){
clearInterval(timer);
index=this.value;
show();
timer=setInterval(auto,3000);


}
</script>
</body>
</html>

最新文章

  1. 考前预习(Ubuntu配备)
  2. Java 设计模式学习
  3. CSS3多列
  4. 网页之间信息传递方式(Cookie,Session)
  5. word2vec模型原理与实现
  6. Dynamics AX 2012 R2 Business Connector Error
  7. IO流 总结二
  8. 从协议VersionedProtocol开始4&mdash;&mdash;AdminOperationsProtocol、InterTrackerProtocol、JobSubmissionProtocol、TaskUmbilicalProtocol
  9. MySQL 操作表命令
  10. 转-问自己:UI设计注意的十个问题
  11. php扩展函数调用扩展中的标准函数
  12. Oracle并行更新的两种方式(merge/update内联视图)
  13. 灵玖软件NLPIRParser智能文本聚类
  14. 利用QuickCHM制作chm
  15. Hbase replication操作
  16. RFC2544测试指标
  17. [图形]图形API的两种模式
  18. hdu 1518 Square 木棍建正方形【DFS】
  19. Tomcat以Daemon的方式启动(CentOS6&amp;7)
  20. MB_SELECT_GR_BLOCKED_STOCK 读取物料收货冻结库存

热门文章

  1. H5播放器
  2. 【Alpha版本】冲刺-Day1
  3. MVC学习笔记
  4. tc674div1b
  5. 【python】装饰器
  6. 在Mac OS X Yosemite 10.10.3 中搭建第一个 ASP.NET 5 Web 项目
  7. 时间戳与日期时间互转C语言
  8. jquery 键盘回车事件
  9. October 18th, Week 43rd Tuesday, 2016
  10. C语言字符串操作总结大全