以下为代码部分:
<style type="text/css">
*{
margin: 0 auto;
width: %100;
}
img{
height: 500px;
width: 1000px;
}
.left{
width: 50px;
height: 50px;
position: absolute;
background-color: aliceblue;
top: 200px;
}
.right{
width: 50px;
height: 50px;
position: absolute;
background-color: aliceblue;
top: 200px;
right: 0px;
}
.t{
width: 60px;
height: 60px;
background-color: white;
border-radius: 30px;
float: left;
margin-left: 50px;
}
.div2 img{
border: dashed;
border-color: brown;
}
</style>
<script type="text/javascript">
//窗口
onload=function(){
//得到图片
imageObj=document.getElementById("image");
//定义时间,设置其属性setInterval
time=setInterval(changeImg,1000);
}
//计数器设置为0
count = 0;
//
function changeImg(){
if(count==3){
count = -1;
}
imageObj.src="img/"+(++count)+".jpg";
changeRadius();
}
function changeRadius(){
radius=document.getElementsByClassName("t");
if(count==0){
radius[0].style.background="black";
radius[1].style.background="white";
radius[2].style.background="white";
radius[3].style.background="white";
}
if(count==1){
radius[0].style.background="white";
radius[1].style.background="black";
radius[2].style.background="white";
radius[3].style.background="white";
}
if(count==2){
radius[0].style.background="white";
radius[1].style.background="white";
radius[2].style.background="black";
radius[3].style.background="white";
}
if(count==3){
radius[0].style.background="white";
radius[1].style.background="white";
radius[2].style.background="white";
radius[3].style.background="black";
}
}
//按钮向左的函数
function pre(){
//
clearInterval(time);
if(count ==0){
count =3;
}
imageObj.src = "img/"+(--count)+".jpg";
time = setInterval(changeImg,2000);
}
function next(){
clearInterval(time);
if(count ==3){
count =-1;
}
imageObj.src = "img/"+(++count)+".jpg";
time = setInterval(changeImg,1000);
}
</script>
</head>
<body>
<div id="" class="div1" style="width: 1000px; height: 500px; position: relative; ">
<!--写一个向右走的按钮;中间是一个图片;右边是一个向右走的按钮; 按钮定义两个事件 onclick="pre()" onclick="next()" -->
<button id="" class="left" onclick="pre()"><</button>
<img src="img/0.jpg" id="image"/>
<button id="" class="right" onclick="next()">></button>
<!--四个圆,应对着四张图片,定义一个class="t"-->
<div class="divs" style="position: absolute; margin-left: 200px; top: 400px;">
<div class="t" style="background-color: black;"></div>
<div class="t"></div>
<div class="t"></div>
<div class="t"></div>
</div>
</div>
<div class="div2" id="" style="height: 200px; width:%100" >
<marquee>
<img src="img/0.jpg"/>
<img src="img/1.jpg"/>
<img src="img/2.jpg"/>
<img src="img/3.jpg"/>
</marquee>
</div>