Js图片切换
<!DOCTYPE html><html<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="css/1.css" />
<style>
在css中,因为p标签有个margin ,所以margin 要置为0,filter:alpha(opacity:80)(兼容IE浏览器); opacity:0.8(兼容火狐浏览器);
p { margin:0; }
body { text-align:center; }
#box { width:400px; height:400px; border:10px solid #ccc; margin:50px auto 0; position:relative; }
a { width:40px; height:40px; background:brown; filter:alpha(opacity:80); opacity:0.8; position:absolute; top:160px; font-size:18px; color:#000; text-align:center; line-height:40px; text-decoration:none; }
a:hover { filter:alpha(opacity:30); opacity:0.3; }
#prev { left:10px; }
#next { right:10px; }
#p1 { width:400px; height:30px; line-height:30px; text-align:center; background:#000; color:#fff; font-size:14px; filter:alpha(opacity:80); opacity:0.8; position:absolute; bottom:0; left:0; }
strong { width:400px; height:30px; line-height:30px; text-align:center; background:#000; color:#fff; font-size:14px; filter:alpha(opacity:80); opacity:0.8; position:absolute; top:0; left:0; }
#img1 { width:400px; height:400px; }
span { position:absolute; width:400px; height:30px; line-height:30px; text-align:center; top:-50px; left:0; font-family:'微软雅黑'; }
</style>
<script type="text/javascript" >
window.onload = function (){
var oPrev = document.getElementById('prev');
var oNext = document.getElementById('next');
var oP = document.getElementById('p1');
var oStrong = document.getElementById('strong1');
var oImg = document.getElementById('img1');
var aBtn = document.getElementsByTagName('input');
var arrUrl = [ 'img/1.jpg', 'img/2.jpg', 'img/3.jpg', 'img/4.jpg' ];
var arrText = [ '文字一', '文字二', '文字三', '识文断字' ];
var num = 0;
var onOff = true;
//初始化
function Tab(){
oStrong.innerHTML=num+1+"/"+arrText.length;
oP.innerHTML=arrText[num];
oImg.src=arrUrl[num];
}
Tab();
aBtn[0].onclick=function(){
onOff=true;
document.getElementsByTagName("span")[0].innerHTML='图片可从最后一张跳转到第一张循环切换';
};
aBtn[1].onclick=function(){
onOff=false;
document.getElementsByTagName("span")[0].innerHTML='图片只能到最后一张或只能到第一张切换';
};
oNext.onclick=function(){
num++;
if(onOff){
if(num==arrText.length){num=0; }
}else{
if(num==arrText.length){alert("这已经是最后一张~~~~~");
num=arrText.length-1;
}
}
Tab();
};
oPrev.onclick=function(){
num--;
if(onOff){
if(num==-1){num=arrText.length-1;}
}else{
if(num==-1){num=num+1;
alert('这已经是第一张了~~~~');}
}
Tab();
}
}
</script>
</head>
<body>
<input type="button" value="循环切换" />
<input type="button" value="顺序切换" />
<div id="box"><span>图片可从最后一张跳转到第一张循环切换</span>
<a id="prev" href="javascript:;"><</a>
<a id="next" href="javascript:;">></a>
<p id="p1">图片文字加载中……</p>
<strong id="strong1">图片数量计算中……</strong>
<img id="img1" />
</div>
</body>
</html>
Js图片切换的更多相关文章
- js 图片切换效果
效果如下: 代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type&quo ...
- JS图片切换效果
源地址:http://www.codefans.net/jscss/code/4699.shtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1 ...
- JS 图片切换
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="zzzz.aspx.cs&quo ...
- 仿淘宝js图片切换
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js图片切换 带左右控制的
代码下载
- JS图片Switchable切换大集合
JS图片切换大集合 利用周末2天把JS图片切换常见效果封装了下,比如:轮播,显示隐藏,淡入淡出等.废话不多说,直接看效果吧!JSFiddler链接如下: 想看JS轮播切换效果请点击我! 当然由于上传图 ...
- js鼠标滚轮滚动图片切换效果
效果体验网址:http://keleyi.com/keleyi/phtml/image/12.htm HTML文件代码: <!DOCTYPE html PUBLIC "-//W3C// ...
- JS图片自动和可控的轮播切换特效
点击这里查看效果:http://hovertree.com/texiao/js/1.htm HTML文件代码如下: <!DOCTYPE html> <html xmlns=" ...
- javascript马赛克遮罩图片切换效果:XMosaic.js(转)
新鲜出炉的javascript图片切换特效,实现的是马赛克遮罩切换.在flash里,好实现遮罩动画很简单,不过JS实现起来就有些困难了. XMosaic.js,与XScroll.js和XScroll2 ...
随机推荐
- codeforces 449B Jzzhu and Cities (Dij+堆优化)
输入一个无向图<V,E> V<=1e5, E<=3e5 现在另外给k条边(u=1,v=s[k],w=y[k]) 问在不影响从结点1出发到所有结点的最短路的前提下,最多可以 ...
- python学习 登陆验证
#!/usr/bin/env python #-*- coding=utf-8 -*- #----------------导入模块------------------------------ impo ...
- [Android Pro] Normal Permissions
As of API level 23, the following permissions are classified as PROTECTION_NORMAL: ACCESS_LOCATION_E ...
- 一分钟可知css3版大白源码
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- instanceof、 isinstance 与 isAssignableFrom的区别
instanceof运算符 只被用于对象引用变量,检查左边的被测试对象 是不是 右边类或接口的 实例化.如果被测对象是null值,则测试结果总是false. 形象地:自身实例或子类实例 instanc ...
- Qt中如何添加.qrc文件
You need a resource file (.qrc) within which you embed the input text file. The input file can be an ...
- 服务器知识----IIS架设问题
1,基本配置,应用程序池,路径等. 2,权限设置 Iuser IIS_users 只读权限 3,isapi映射 framework安装目录下 运行 aspnet_regiis.exe -i 注 ...
- Linq to json
Json.Net系列教程 4.Linq To JSON 一.Linq to JSON是用来干什么的? Linq to JSON是用来操作JSON对象的.可以用于快速查询,修改和创建JSON对象.当JS ...
- C#的初始化器
using System; using System.Collections; using System.Collections.Generic; using System.IO; using Sys ...
- 14.模板方法模式(Template Method)
using System; namespace ConsoleApplication7 { class Program { /// <summary> /// 模板方法模式——在一个抽象类 ...