<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图片切换</title>
<style>
.box{
width: 600px;
height:400px;
border: 10px solid #ccc;
position: relative;
margin: 40px auto 0;
}
.box a{
width: 30px;
height: 30px;
background-color: #000;
border: 5px solid #fff;
position: absolute;
top:180px;
text-align: center;
font-size:25px;
font-weight: bold;
line-height: 30px;
color:#fff;
text-decoration: none;
filter: alpha(opacity:40);
opacity: 0.4;
}
.box a:hover{
filter:alpha(opacity:80);
opacity:0.8;
}
.box #prev{
left: 10px;
}
.box #next{
right: 10px;
}
#text,#num{
height: 30px;
line-height:30px;
width: 600px;
color:#fff;
position: absolute;
left: 0;
background-color: #000;
text-align: center;
filter: alpha(opacity:80);
opacity: 0.8;
margin:0;
}
.box #text{
bottom: 0;
}
.box #num{
top:0;
}
.box #img1{
width: 600px;
height: 400px;
}
</style>
<script>
window.onload = function () {
var oPrev = document.getElementById("prev");
var oNext = document.getElementById("next");
var oText = document.getElementById("text");
var oNum = document.getElementById("num");
var oImg = document.getElementById("img1");
var arrUrl = ['images/1.jpg','images/2.jpg','images/3.jpg','images/4.jpg'];
var arrText = ['文字1','文字2','文字3','文字4'];
//初始化
var num = 0;
function fnTab(){
oNum.innerHTML = num + 1 + '/' + arrText.length;
oImg.src = arrUrl[num];
oText.innerHTML = arrText[num];
};
fnTab();
oPrev.onclick = function(){
num --;
if( num == -1){
num = arrUrl.length -1;
}
fnTab();
};
oNext.onclick = function(){
num ++;
if(num == arrUrl.length){
num = 0;
}
fnTab();
};
};
</script>
</head>
<body>
<div class="box">
<a id="prev" href="javascript:;"> < </a>
<a id="next" href="javascript:;"> > </a>
<p id="text">图片正在加载中……</p>
<span id="num">数量正在统计中……</span>
<img id="img1" src="../images/1.jpg" alt="">
</div>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有