JS + CSS 图片切换效果
来源:互联网 发布:足球黑色三分钟 知乎 编辑:程序博客网 时间:2024/06/04 17:41
[javascript] view plain copy
- <div id="xxx">
- <script>
- var box =new PPTBox();
- box.width = 998; //宽度
- box.height = 323;//高度
- box.autoplayer = 3;//自动播放间隔时间
- //box.add({"url":"图片地址","title":"悬浮标题","href":"链接地址"})
- box.add({"url":"images/home_27.jpg","href":"#","title":"悬浮提示标题1"})
- box.add({"url":"images/home_27.jpg","href":"#","title":"悬浮提示标题2"})
- box.add({"url":"images/home_27.jpg","href":"#","title":"悬浮提示标题3"})
- box.add({"url":"images/home_27.jpg","href":"#","title":"悬浮提示标题4"})
- box.show();
- </script>
- </div>
[css] view plain copy
- <script type="text/javascript" src="js/pptBox.js"></script>
- <style>
- /* 焦点图 */
- .mainbox{
- overflow:hidden;
- position:relative;
- }
- .flashbox{
- overflow:hidden;
- position:relative;
- }
- .imagebox{
- text-align:center;position:relative;z-index:999;
- }
- .bitdiv{display:inline-block;width:18px;height:18px;margin:0 10px 10px 0px;cursor:pointer;}
- .defimg{background-image:url(images/02.png)}
- .curimg{background-image:url(images/01.png)}
- </style>
js/pptBox.jsjs/pptBox.js 文件
[javascript] view plain copy
- /**
- * 网络剑客 2012-10-27
- */
- function PPTBox()
- {
- this.uid = PPTBoxHelper.getId();
- PPTBoxHelper.instance[this.uid] = this;
- this._$ = function(id){return document.getElementById(id);};
- this.width = 988;//宽度
- this.height = 323;//高度
- this.picWidth = 15;//小图宽度
- this.picHeight = 12;//小图高度
- this.autoplayer = 4;//自动播放间隔(秒)
- this.target = "_blank";
- this._box = [];
- this._curIndex = 0;
- }
- PPTBox.prototype =
- {
- _createMainBox : function (){
- var flashBoxWidth = this.width * this._box.length + 5;
- var html="<div id='"+this.uid+"_mainbox' class='mainbox' style='width:"+(this.width)+"px;height:"+(this.height+2)+"px;'>";
- html += "<div id='"+this.uid+"_flashbox' class='flashbox' style='width:"+flashBoxWidth+"px;height:"+(this.height+2)+"px;'></div>";
- html += "<div id='"+this.uid+"_imagebox' class='imagebox' style='width:"+this.width+"px;height:"+(this.picHeight+2)+"px;top:-"+(this.picHeight+20)+"px;'></div>";
- html += "</div>";
- document.write(html);
- },
- _init : function (){
- var picstyle= "";
- var eventstr = "PPTBoxHelper.instance['"+this.uid+"']";
- var imageHTML="";
- var flashbox = "";
- for(var i=0;i<this._box.length;i++){
- var parame = this._box[i];
- flashbox += this.flashHTML(parame.url,this.width,this.height,i);
- imageHTML ="<div class='bitdiv "+((i==0)?"curimg":"defimg")+"' title ="+parame.title+" src='bit01.gif' "+picstyle+" onclick = \""+eventstr+".clickPic("+i+")\" onmouseover=\""+eventstr+".mouseoverPic("+i+")\"></div>" + imageHTML;
- }
- this._$(this.uid+"_flashbox").innerHTML = flashbox;
- this._$(this.uid+"_imagebox").innerHTML = imageHTML;
- },
- _play : function(){
- clearInterval(this._autoplay);
- var idx = this._curIndex+1;
- if(idx>=this._box.length){idx=0;}
- this.changeIndex(idx);
- var eventstr = "PPTBoxHelper.instance['"+this.uid+"']._play()";
- this._autoplay = setInterval(eventstr,this.autoplayer*1000);
- },
- flashHTML : function(url,width,height,idx) {
- var isFlash = url.substring(url.lastIndexOf('.')+1).toLowerCase()=="swf";
- var html = "";
- if(isFlash){
- html = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "
- + "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+width+"' height='"+height+"'>"
- + "<param name=\"movie\" value=\""+url+"\" />"
- + "<param name='quality' value='high' />"
- + "<param name='wmode' value='transparent'>"
- + "<embed src='"+url+"' quality='high' wmode='opaque' pluginspage='http://www.macromedia.com/go/getflashplayer'"
- +" type='application/x-shockwave-flash' width="+width+" height='"+height+"'></embed>"
- +" </object>";
- } else {
- var eventstr = "PPTBoxHelper.instance['"+this.uid+"']";
- var style = "";
- if(this._box[idx].href){
- style = "cursor:pointer"
- }
- html="<img src='"+url+"' style='width:"+width+"px;height:"+height+"px;"+style+"' onclick = \""+eventstr+".clickPic("+idx+")\"/>";
- }
- return html;
- },
- changeIndex : function(idx){
- var parame = this._box[idx];
- moveElement(this.uid+"_flashbox",-(idx*this.width),1);
- var imgs = this._$(this.uid+"_imagebox").getElementsByTagName("div");
- imgs[this._box.length-1-this._curIndex].className = "bitdiv defimg";
- imgs[this._box.length-1-idx].className = "bitdiv curimg";
- this._curIndex = idx;
- },
- mouseoverPic:function(idx){
- this.changeIndex(idx);
- if(this.autoplayer>0){
- clearInterval(this._autoplay);
- var eventstr = "PPTBoxHelper.instance['"+this.uid+"']._play()";
- this._autoplay = setInterval(eventstr,this.autoplayer*1000);
- }
- },
- clickPic:function(idx){
- var parame = this._box[idx];
- if(parame.href&¶me.href!=""){
- window.open(parame.href,this.target);
- }
- },
- add:function (imgParam){
- this._box[this._box.length] = imgParam;
- },
- show : function () {
- this._createMainBox();
- this._init();
- if(this.autoplayer>0){
- var eventstr = "PPTBoxHelper.instance['"+this.uid+"']._play()";
- this._autoplay = setInterval(eventstr,this.autoplayer*1000);
- }
- }
- }
- var PPTBoxHelper =
- {
- count: 0,
- instance: {},
- getId: function() { return '_ppt_box-' + (this.count++); }
- };
- function moveElement(elementID,final_x,interval) {
- if (!document.getElementById) return false;
- if (!document.getElementById(elementID)) return false;
- var elem = document.getElementById(elementID);
- if (elem.movement) {
- clearTimeout(elem.movement);
- }
- if (!elem.style.left) {
- elem.style.left = "0px";
- }
- var xpos = parseInt(elem.style.left);
- if (xpos == final_x ) {
- return true;
- }
- if (xpos < final_x) {
- var dist = Math.ceil((final_x - xpos)/5);
- xpos = xpos + dist;
- }
- if (xpos > final_x) {
- var dist = Math.ceil((xpos - final_x)/5);
- xpos = xpos - dist;
- }
- elem.style.left = xpos + "px";
- var repeat = "moveElement('"+elementID+"',"+final_x+","+interval+")";
- elem.movement = setTimeout(repeat,interval);
- }
0 0
- JS + CSS 图片切换效果
- JS + CSS 图片切换效果
- 图片切换效果JS
- JS图片切换效果
- JS图片切换效果
- js图片切换效果
- 纯js +css 仿flash 图片切换效果代码
- css列表 图片切换效果
- css 实现图片切换效果
- js图片切换 幻灯片效果
- js图片滑动切换效果
- JS切换图片幻灯切换效果
- JS+CSS图片新闻效果
- 滚动广告pptBox_JS + CSS 图片切换效果
- 图片切换效果beta3纯CSS构造
- JS+CSS打造腾讯网漂亮的带缩略图的图片幻灯切换效果
- js+css打造的仿土豆网带缩略图的图片幻灯切换效果
- JS + CSS 超漂亮切换效果
- 一念永恒 > 第134章 阴魂不散……
- HTML5新标签video在iOS上默认全屏播放
- iOS UITableView(一)-纯代码创建UITableView,Cell点击事件,Cell左滑删除
- Linux学习之Vim(-)-常用操作导航集锦
- 正版ipa加载dylib且正常运行思路
- JS + CSS 图片切换效果
- android-多分辨率适配的思路
- python3.5入门1--运行报错:IndentationError: expected an indented block
- Ansoft HFSS____百度百科
- 删除链表中重复的结点
- 控制webview使用html5的video播放视频不全屏(inline)的方法
- Hibernate 缓存 之 Session 实现(一)
- 小萝莉五子棋(高能绕行)
- 社会变革、新医改与医疗信息化