首页 技术 正文
技术 2022年11月18日
0 收藏 349 点赞 3,923 浏览 4277 个字

//html部分

 <div id="wrap">
<div id="slider">
<a target="_blank" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img class="tu" src="../img/tu1.jpg" /></a>
<a target="_blank" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img id="second" /></a>
<a target="_blank" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img id="third" /></a>
<a target="_blank" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img id="four" /></a>
</div>
<ul id="ui">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>

//css 部分

 <style type="text/css">
#wrap
{
height: 500px;
width: 500px;
overflow: hidden;
position: relative;
overflow: hidden;
}
#wrap ul
{
list-style: none;
position: absolute;
top: 455px;
left: 332px; }
#wrap li
{
margin-left:2px;
opacity:0 .3;
filter: alpha(opacity=30);
text-align: center;
line-height: 30px;
font-size: 20px;
height: 30px;
width: 30px;
background-color: #fff;
float: left;
border-radius:3px;
cursor:pointer;
}
#slider
{
position: absolute;
top: 0px;
left: 0px;
}
#slider img
{
float: left;
border: none;
}
.tu{
height: 500px;
width: 500px;
}
#ui{
z-index:;
}

//js 部分

 <script type="text/javascript">
window.onload = function () {
flag = 0;
obj1 = document.getElementById("slider");
obj2 = document.getElementsByTagName("li");
obj2[0].style.backgroundColor = "#666666";
//默认被选中颜色
time = setInterval("turn();", 2000);
obj1.onmouseover = function () {
clearInterval(time);
}
obj1.onmouseout = function () {
time = setInterval("turn();", 2000);
} for (var num = 0; num < obj2.length; num++) {
obj2[num].onmouseover = function () {
turn(this.innerHTML);
clearInterval(time);
}
obj2[num].onmouseout = function () {
time = setInterval("turn();", 2000);
}
}
//延迟加载图片,演示的时候,使用本地图片
//上线后请改为二级域名提供的图片地址
document.getElementById("second").src = "../img/tu2.jpg";
document.getElementById("second").width ="500";
document.getElementById("second").height ="500"; //使用图片宽660,高550
document.getElementById("third").src = "../img/tu3.jpg";
document.getElementById("third").width ="500";
document.getElementById("third").height ="500";
document.getElementById("four").src = "../img/tu4.jpg";
document.getElementById("four").width ="500";
document.getElementById("four").height ="500";
}
function turn(value) {
if (value != null) {
flag = value - 2;
}
if (flag < obj2.length - 1)
flag++;
else
flag = 0;
obj1.style.top = flag * (-500) + "px";
for (var j = 0; j < obj2.length; j++) {
obj2[j].style.backgroundColor = "#ffffff";
}
obj2[flag].style.backgroundColor = "#666666";
}
</script>

//源代码

 <!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS幻灯代码</title>
<script type="text/javascript">
window.onload = function () {
flag = 0;
obj1 = document.getElementById("slider");
obj2 = document.getElementsByTagName("li");
obj2[0].style.backgroundColor = "#666666";
//默认被选中颜色
time = setInterval("turn();", 2000);
obj1.onmouseover = function () {
clearInterval(time);
}
obj1.onmouseout = function () {
time = setInterval("turn();", 2000);
} for (var num = 0; num < obj2.length; num++) {
obj2[num].onmouseover = function () {
turn(this.innerHTML);
clearInterval(time);
}
obj2[num].onmouseout = function () {
time = setInterval("turn();", 2000);
}
}
//延迟加载图片,演示的时候,使用本地图片
//上线后请改为二级域名提供的图片地址
document.getElementById("second").src = "../img/tu2.jpg";
document.getElementById("second").width ="500";
document.getElementById("second").height ="500"; //使用图片宽660,高550
document.getElementById("third").src = "../img/tu3.jpg";
document.getElementById("third").width ="500";
document.getElementById("third").height ="500";
document.getElementById("four").src = "../img/tu4.jpg";
document.getElementById("four").width ="500";
document.getElementById("four").height ="500";
}
function turn(value) {
if (value != null) {
flag = value - 2;
}
if (flag < obj2.length - 1)
flag++;
else
flag = 0;
obj1.style.top = flag * (-500) + "px";
for (var j = 0; j < obj2.length; j++) {
obj2[j].style.backgroundColor = "#ffffff";
}
obj2[flag].style.backgroundColor = "#666666";
}
</script>
<style type="text/css">
#wrap
{
height: 500px;
width: 500px;
overflow: hidden;
position: relative;
overflow: hidden;
}
#wrap ul
{
list-style: none;
position: absolute;
top: 455px;
left: 332px; }
#wrap li
{
margin-left:2px;
opacity:0 .3;
filter: alpha(opacity=30);
text-align: center;
line-height: 30px;
font-size: 20px;
height: 30px;
width: 30px;
background-color: #fff;
float: left;
border-radius:3px;
cursor:pointer;
}
#slider
{
position: absolute;
top: 0px;
left: 0px;
}
#slider img
{
float: left;
border: none;
}
.tu{
height: 500px;
width: 500px;
}
#ui{
z-index: 999;
} </style>
</head>
<body>
<div id="wrap">
<div id="slider">
<a target="_blank" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img class="tu" src="../img/tu1.jpg" /></a>
<a target="_blank" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img id="second" /></a>
<a target="_blank" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img id="third" /></a>
<a target="_blank" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img id="four" /></a>
</div>
<ul id="ui">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
</body>
</html>

// 效果预览

用js 做大图轮播方法(一)

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918