HTML纯javaScript代码写图片轮播
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.imgbox {
width: 100%;
height: 400px;
position: relative;
top: 20px;
left: 15px;
} img {
opacity: 0;
position: absolute;
max-height: 400px;
max-width: 300px;
}
</style>
</head> <body>
<div class="imgbox" id="imgbox">
<img src="img/19.jpg" style="opacity: 1;" alt="" />
<img src="img/20.jpg" alt="" />
<img src="img/21.jpg" alt="" />
<img src="img/22.jpg" alt="" />
<img src="img/23.jpg" alt="" />
<img src="img/24.jpg" alt="" />
</div>
<input type="button" value="切换" onclick="change()" />
<script>
//全局地址
var index = 0; function change() {
//得到所 有图片长度
var imgs = document.getElementsByTagName("img").length;
var next = index + 1;
if (index == imgs - 2) {
//imgs-1为长度(从0开始);imgs-2为index(next+1)
next = 0;
}
//得到所有图片元素
var img = document.getElementById("imgbox").children;
img[index].style.opacity = 0;
img[next].style.opacity = 1;
index = next;
console.log(index);
}
window.setInterval("change()", 2000);
</script>
</body> </html>
HTML纯javaScript代码写图片轮播的更多相关文章
- javaScript 手写图片轮播
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 利用bootstrap写图片轮播
利用bootstrap写图片轮播 缺点是轮播没有固定样式图片样式会改变外框的大小,所以要再设置 以及左右按钮的style也要从新设置 <div class="carousel slid ...
- 纯js写图片轮播插件
最近终于写成了自己创作的图片轮播插件,使用原生js编写.与目前网上流行的轮播插件相比,功能和效果稍弱,但是使用起来相当方便. 先看html代码 <!DOCTYPE html> <ht ...
- JavaScript学习---简易图片轮播
效果如下: 图片定时轮播 点击左右控制显示下一张或上一张图片 index.html文件 <html> <head> <title> js编写实现幻灯片效果 < ...
- JavaScript数组实现图片轮播
最终效果 注:图片来源于百度图片 文件结构: 代码: <!DOCTYPE html> <html> <head> <meta charset="UT ...
- 纯javaScript、jQuery实现个性化图片轮播
纯javaScript实现个性化图片轮播 轮播原理说明<如上图所示>: 1. 画布部分(可视区域)属性说明:overflow:hidden使得超出画布部分隐藏或说不可见.position: ...
- 使用纯css3实现图片轮播
<!DOCTYPE html> <html> <head> <title> 飛天网事--纯CSS代码实现图片轮播 </title> < ...
- Javascript和jQuery WordPress 图片轮播插件, 内容滚动插件,前后切换幻灯片形式显示
用于在有限的网页空间内展示一组产品图片或者照片,同时还有非常吸引人的动画效果.本文向大家推荐12款实用的 jQuery 图片轮播效果插件,帮助你在你的项目中加入一些效果精美的图片轮播效果,希望这些插件 ...
- 推荐一款超级漂亮的HTML5 CSS3的图片轮播器
最近在学习HTML5和CSS3,印象最深的是CSS3的动画功能,不仅有浏览器原生支持,执行效率高,而且免去在js中自己管理timer. 本来想写一个图片轮播器练练手,结果在网上发现一个国人写的开源的图 ...
随机推荐
- 【运维工具】Git代码发布系统
引言 代码发布系统是互联网公司必备的运维系统,作用主要用户发布业务代码 到 业务服务器 为什么需要代码发布系统 有的同学可能说,我们公司服务器就那么一台,做个发布系统太麻烦了? 不认同这说法 发布系统 ...
- +Load和+initialize方法解析
http://www.cnblogs.com/ider/archive/2012/09/29/objective_c_load_vs_initialize.html
- ajax跨域通过 Cors跨域资源共享 进行GetPost请求
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Ne ...
- ElasticSearchwindow下搭建
ElasticSearch是一个开源的分布式搜索引擎. 下载 下载地址: https://www.elastic.co/downloads/elasticsearch 当前版本:Elasticsear ...
- GridView实现方块布局
效果如下: 先创建一个BaseViewHolder package com.example.griddemo; import android.util.SparseArray; import andr ...
- 【leedcode】add-two-numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...
- LeetCode Minimum Moves to Equal Array Elements II
原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/ 题目: Given a non-empt ...
- Python模块和包
模块和包是python组织代码的基本方式. 模块: python的每一个脚本文件都可称之为模块,模块的名称就是脚本的文件名.例如当我们写了一个test.py的脚本文件,则可以在同目录下的另外一个脚本m ...
- Macaca开源--阿里的移动自动化测试框架
https://github.com/macacajs/macaca-cli 项目在此 https://macacajs.github.io/macaca/cli-usage.html 文档在此 项目 ...
- >>> 主页推荐链接
Apple专区 App Store 排行榜 App Store 排行榜 - 中国区 PC6苹果网 威锋网 第三方 环信 - 即时通讯云领导者 腾讯Bugly - Android Crash | iOS ...