首页 > 代码库 > HTML+CSS+JavaScript网络相册【有缩略图】
HTML+CSS+JavaScript网络相册【有缩略图】
今晚整理了一下,把班级相册弄了一下,加了个缩略图,版本有点丑,下个版本再更新吧。
1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>大肥</title>
<style type="text/css">
div{margin:0px auto;}
.box{width: 800px;height: 530px;overflow: hidden;border-radius: 10px;}
.thum{height: 200px;width: 1500px;margin-top: 50px;}
ul{list-style: none;margin:0px;padding: 0px;}
li{float: left;}
.thumbs_none{opacity:0.6;filter:alpha(opacity=40); }
</style>
<script type="text/javascript">
//定义一个变量控制全局定时器
var times;
window.onload=function(){
//用变量控制定时器
times = setInterval(‘lb()‘,1000);
}
//图片轮播方法
var i=2;
function lb(){
//获取src属性 更改图片路径
var info = document.getElementById("img");
var thu=document.getElementById("thumbs");
var li_list=document.getElementsByTagName("li");
for (var j = 1; j<li_list.length;j++) {
//给所有缩略图添加透明样式
li_list[j].className="thumbs_none";
//匹配缩略图 同步去除透明度
if(j==i){
li_list[j].className="";
}
}
//移除透明度样式
thu.className="";
info.src="http://www.mamicode.com/"+i+".JPG";
//运行后i+1 到达最大数时候回归清零
i++;
if(i>23){
i=1;
}
}
//鼠标经过停止
function stop(){
//清理定时器
clearInterval(times);
}
//鼠标离开继续轮播
function again(){
//清除定时器的时候要把这个也要清除 否则两个同时运行会重叠
times = setInterval(‘lb()‘,1000);
}
</script>
</head>
<body>
<div class="box">
<ul><li><img src="http://www.mamicode.com/1.JPG" id="img" onm ouseover="stop()" onm ouseout="again()" /></li> </ul> </div>
<div class="thum">
<ul class="tbs">
<!-- 这里没用js 暂时不写 下个版本再改进 -->
<li class=""><img src="http://www.mamicode.com/thumbs/1.JPG" id="thumbss" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/2.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/3.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/4.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/5.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/6.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/7.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/8.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/9.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/10.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/11.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/12.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/13.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/14.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/15.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/16.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/17.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/18.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/19.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/20.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/21.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/22.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
<li class="thumbs_none"><img src="http://www.mamicode.com/thumbs/23.JPG" id="thumbs" onm ouseover="stop()" onm ouseout="again()" class="" /></li>
</ul>
</div>
</body>
</html>
效果图如下:
在线演示地址:http://bbqwifi.info/php/show/ 不过图片上传后好像有点延迟,大家别介意。
HTML+CSS+JavaScript网络相册【有缩略图】