`
bean-woo
  • 浏览: 134188 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
社区版块
存档分类
最新评论

3D盒子图片切换效果

阅读更多

<!doctype html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style>

html {background:#000}

body, ul {margin:0;padding:0}

li {list-style:none}

img {border:none;display:block}

.slide-wp {

width: 520px;

height: 280px;

overflow: hidden;

position: absolute;

left: 50%;

top: 50%;

margin-left: -250px;

margin-top: -150px;

}

.nav-wp {

position: absolute;

background: #ccc;

top: 50%;

margin-top: 170px;

left: 50%;

margin-left: -100px;

border-radius: 4px;

-moz-border-radius: 4px;

-webkit-border-radius: 4px;

padding: 0 20px 6px 10px;

_padding: 0 20px 2px 10px;

}

.nav li {

float: left;

margin-left: 10px;

font-size: 20px;

font-weight: bold;

font-family: tahoma;

color: #22739e;

cursor: pointer;

height: 22px;

}

.nav li.cur{color: #ff7a00}

.next {

position:absolute;

top: 0;

left: 160px;

padding: 4px 8px;

color: #ff7a00;

background: #ccc;

height: 20px;

border-radius: 4px;

-moz-border-radius: 4px;

-webkit-border-radius: 4px;

cursor: pointer;

}

</style>

</head>

<body>

<h2 style="color:#fff">对于使用IE6的同学看到的斑点,我只能表示很无奈。。。</h2>

<div id="slider" class="slide-wp">

<ul>

<li><a href="http://www.nowamagic.net/" target="_blank"><img src="http://www.nowamagic.net/images/1.jpg"  alt="" /></a></li>

<li><a href="http://www.nowamagic.net/" target="_blank"><img src="http://www.nowamagic.net/images/2.jpg"  alt="" /></a></li>

<li><a href="http://www.nowamagic.net/" target="_blank"><img src="http://www.nowamagic.net/images/3.jpg"  alt="" /></a></li>

<li><a href="http://www.nowamagic.net/" target="_blank"><img src="http://www.nowamagic.net/images/4.jpg"  alt="" /></a></li>

<li><a href="http://www.nowamagic.net/" target="_blank"><img src="http://www.nowamagic.net/images/5.jpg"  alt="" /></a></li>

</ul>

</div>

<div class="nav-wp">

<ul id="nav" class="nav">

<li onclick="mySlider.pos(0)">●</li>

<li onclick="mySlider.pos(1)">●</li>

<li onclick="mySlider.pos(2)">●</li>

<li onclick="mySlider.pos(3)">●</li>

<li onclick="mySlider.pos(4)">●</li>

</ul>

<a class="next" onclick="mySlider.move()">next</a>

</div>

<script type="text/javascript">

var HR = {

 $ : function(i) {return document.getElementById(i)},

 $$ : function(c, p) {return p.getElementsByTagName(c)},

 ce : function(i, t) {

  var o = document.createElement(i);

  t.appendChild(o);

  return o;

 }

};

HR.slider3D = function () {

 var init = function (o) {

  this.o = o;

  var wp = HR.$(o.id), ul = HR.$$('ul', wp)[0], li = this.li = HR.$$('li', ul);

  this.l = li.length;

  this.w = wp.offsetWidth;

  this.h = wp.offsetHeight;

  this.at = o.auto? o.auto : 4;

  var con = this.con = HR.ce('div', wp);

  con.style.cssText = 'position:absolute;left:0;top:0;width:'+this.w+'px;height:'+this.h+'px';

  ul.style['display'] = 'none';  

  this.a1 = HR.ce('a', con);  

  this.a1.style.cssText = 'position:absolute;left:0;top:0;overflow:hidden';  

  this.a2 = HR.ce('a', con);

  this.a2.style.cssText = 'position:absolute;top:0;right:0;overflow:hidden';

  this.a1.innerHTML = this.a2.innerHTML = '<img alt="" />';

  this.img = HR.$$('img', ul);

  this.s = o.maskSize ? o.maskSize : 5;

 

  this.mask11 = HR.ce('span', this.a1);

  this.mask12 = HR.ce('span', this.a1);

  this.mask21 = HR.ce('span', this.a2);

  this.mask22 = HR.ce('span', this.a2);

 

  this.pos(0);

 }

 init.prototype = {

  pos : function (i) {

   clearInterval(this.li[i].a); clearInterval(this.au); this.au = 0; this.cur = i;

   var navli = HR.$$('li', HR.$(this.o.navId));

   for (var j=0; j<navli.length; j++) {

    navli[j].className = i == j ? 'cur' : '';

   }

   var img1 = HR.$$('img', this.a1)[0], img2 = HR.$$('img', this.a2)[0], _this = this;

   img1.src = i==0 ? this.img[this.l-1].src : this.img[i-1].src;

   img1.width = this.w;

   img2.src = this.img[i].src;

   img2.width = 0;

   img1.height = img2.height = this.h;

   this.mask11.style.cssText = 'position:absolute;left:0;top:0;font-size:0;overflow:hidden;width:0;height:0;border-color:black transparent transparent black;border-style:solid dashed dashed solid;border-width:0 '+this.w/2+'px';

   this.mask12.style.cssText = 'position:absolute;left:0;bottom:0;font-size:0;overflow:hidden;width:0;height:0;border-color:transparent transparent black black;border-style:dashed dashed solid solid;border-width:0 '+this.w/2+'px';

   this.mask21.style.cssText = 'position:absolute;right:0;top:0;font-size:0;overflow:hidden;width:0;height:0;border-color:black black transparent transparent;border-style:solid solid dashed dashed;border-width:0px';

   this.mask22.style.cssText = 'position:absolute;right:0;bottom:0;font-size:0;overflow:hidden;width:0;height:0;border-color:transparent black black transparent;border-style:dashed solid solid dashed;border-width:0px';

   this.li[i].a = setInterval(function(){_this.anim(i)}, 20);

  },

  anim : function (i) {

   var w1 = HR.$$('img', this.a1)[0].width, w2  = HR.$$('img', this.a2)[0].width;

   if (w2 == this.w) {

    clearInterval(this.li[i].a);

    HR.$$('img', this.a1)[0].width = 0;

    HR.$$('img', this.a2)[0].width = this.w;

    this.mask11.style.borderLeftWidth = this.mask11.style.borderRightWidth = this.mask12.style.borderLeftWidth = this.mask12.style.borderRightWidth = '0px';

    this.mask11.style.borderTopWidth = this.mask11.style.borderBottomWidth = this.mask12.style.borderTopWidth = this.mask12.style.borderBottomWidth = this.h/this.s + 'px';

    this.mask21.style.borderLeftWidth = this.mask21.style.borderRightWidth = this.mask22.style.borderLeftWidth = this.mask22.style.borderRightWidth = this.w/2 + 'px';

    this.mask21.style.borderTopWidth = this.mask21.style.borderBottomWidth = this.mask22.style.borderTopWidth = this.mask22.style.borderBottomWidth = '0px';

   }else {

    HR.$$('img', this.a1)[0].width -= Math.ceil((this.w-w2)*.13);

    HR.$$('img', this.a2)[0].width += Math.ceil((this.w-w2)*.13);

    this.mask11.style.borderLeftWidth = this.mask11.style.borderRightWidth = this.mask12.style.borderLeftWidth = this.mask12.style.borderRightWidth = HR.$$('img', this.a1)[0].width/2 + 'px';

    this.mask11.style.borderTopWidth = this.mask11.style.borderBottomWidth = this.mask12.style.borderTopWidth = this.mask12.style.borderBottomWidth = HR.$$('img', this.a2)[0].width*this.h/(this.s*this.w) + 'px';

    this.mask21.style.borderLeftWidth = this.mask21.style.borderRightWidth = this.mask22.style.borderLeftWidth = this.mask22.style.borderRightWidth = HR.$$('img', this.a2)[0].width/2 + 'px';

    this.mask21.style.borderTopWidth = this.mask21.style.borderBottomWidth = this.mask22.style.borderTopWidth = this.mask22.style.borderBottomWidth = this.h/this.s - HR.$$('img', this.a2)[0].width*this.h/(this.s*this.w) + 'px';

    if (!this.au) this.auto();

   }

  },

  auto : function () {

   var _this = this;

   this.au = setInterval(function(){_this.move()}, this.at*1000);

  },

  move : function () {

   var n = this.cur==this.l-1 ? 0 : this.cur+1;

   this.pos(n);

  }

 }

 return init;

}();

var mySlider = new HR.slider3D({

 id: 'slider',

 maskSize: 6,

 navId: 'nav',

 auto: 4

})</script></body>

</html>


分享到:
评论

相关推荐

    3d盒子翻转切换界面和coverflow特效

    "3D盒子翻转切换界面"和"Coverflow特效"就是其中两种常见的视觉效果,广泛应用于网站、APP和其他多媒体展示领域。这两种效果能够为用户带来新颖且引人入胜的互动体验。 首先,我们来详细解读"3D盒子翻转切换界面"。...

    jQuery自定义图片3D盒子旋转代码.zip

    【jQuery自定义图片3D盒子旋转代码】是一个利用jQuery库结合Vue.js框架实现的3D效果的图片展示项目。此项目旨在为用户提供一种创新且吸引人的方式来展示一组图片,通过3D旋转的效果,使用户可以从不同的角度查看图片...

    HTML3D轮播切换图片源码附注释.rar

    源码使用CSS属性+原生js代码实现图片轮播切换、图片整体跟随鼠标移动效果、图片整体鼠标滚轮控制缩放,使用的css属性包括:弹性盒布局元素居中、背景图片平铺尺寸设置、相对、绝对定位、滤镜效果、图片层级、边距...

    jQuery自定义图片3D盒子旋转代码

    图片切换功能通常涉及数组存储图片信息,然后通过Vue的循环指令(如v-for)将每张图片渲染到对应的3D盒子里。同时,可能还有上一张/下一张的切换按钮,通过Vue的方法来改变当前显示的图片索引,实现图片的动态切换。...

    jQuery宽屏3D旋转切换图片代码.zip

    开发者可以通过查看和修改这个文件来定制自己的图片切换效果。 3. **说明.txt**:通常这是一个纯文本文件,提供了额外的指导或注意事项,可能包括版权信息和版本更新等。 4. **css**:这个文件夹包含了样式表文件,...

    CSS3创意3D鞋子产品切换展示特效

    在这个特效中,用户可以通过点击不同的3D盒子来查看不同款式的鞋子,实现3D翻转效果,增强产品展示的立体感和交互性。 **CSS3详解** CSS3是层叠样式表(Cascading Style Sheets)的第三个版本,相比前两个版本,它...

    非常漂亮的100个 jquery前端案例,包含幻灯片切换、图片缩放、相册、放大镜、图片拖着滚动等.zip

    jQuery仿新浪新闻图片浏览器(支持鼠标左右滚动控制图片切换) jquery仿苏宁易购商城产品图片全方位展示功能 jquery制作漂亮按钮示例打包 jQuery动态切换网页背景的大块图片的导航栏代码 jquery图文排行混合互相切换...

    JavaScript_JQuery_CSS_CSS_DIV漂亮的实例123个

    95. 常用jQuery新闻焦点图片切换效果插件 96. 强大jQuery实现3D文字三维旋转效果代码下载 97. 很帅的jquery焦点图切换源码可用于产品大图展示 98. 很帅的jQuery鼠标移动预览图展示+简介内容展示特效代码 99. ...

    100多个JQuery效果示例(实例)div+css+javascrpit

    95. 常用jQuery新闻焦点图片切换效果插件 96. 强大jQuery实现3D文字三维旋转效果代码下载 97. 很帅的jquery焦点图切换源码可用于产品大图展示 98. 很帅的jQuery鼠标移动预览图展示+简介内容展示特效代码 99. ...

    MinuyCube立方体照片盒子.rar

    而“照片盒子”则可能是指将图片纹理应用到立方体表面,形成一个可以展示多张照片的3D容器。通过这个项目,你可以学习如何创建和操作3D物体,以及如何将2D图像映射到3D表面上。 在文件列表中,"MinuyCube立方体照片...

    jquery 动态示例

    95. 常用jQuery新闻焦点图片切换效果插件 96. 强大jQuery实现3D文字三维旋转效果代码下载 97. 很帅的jquery焦点图切换源码可用于产品大图展示 98. 很帅的jQuery鼠标移动预览图展示+简介内容展示特效代码 99. ...

    JavaScript_JQuery_CSS_DIV漂亮的实例

    13. jQuery仿新浪新闻图片浏览器(支持鼠标左右滚动控制图片切换) 14. jquery仿苏宁易购商城产品图片全方位展示功能 15. jquery制作漂亮按钮示例打包 16. jQuery动态切换网页背景的大块图片的导航栏代码 17. ...

    Skybox天空盒子

    在3D图形渲染中,由于Skybox位于场景的最远端,所以它的绘制成本相对较低,对性能影响小,但对整体视觉效果的提升却非常明显。 在给定的文件"SkyBox.360.VR.Transitions.Pack.v13012017"中,我们可以推断这可能是一...

    UNITY3D 照片墙

    Unity的 Animator 和 Animation Controller 可以用来实现动画效果,如淡入淡出、滑动切换等。 在交互性方面,可以添加按钮(Button)组件来触发照片的放大预览、翻转、旋转等行为。事件系统(Event System)和事件...

    JQuery&CSS;&CSS;+DIV实例大全.rar

    13.jQuery仿新浪新闻图片浏览器(支持鼠标左右滚动控制图片切换) 14.jquery仿苏宁易购商城产品图片全方位展示功能 15.jquery制作漂亮按钮示例打包 16.jQuery动态切换网页背景的大块图片的导航栏代码 17....

    js圆形图片旋转的焦点图特效代码.rar

    5. **箭头按钮控制**:左下角和右上角的箭头按钮是控制图片切换的交互元素,它们的点击事件也需要绑定相应的JavaScript函数来处理图片的前进或后退。 6. **兼容性处理**:提到在Chrome或Firefox下效果更佳,意味着...

    基于vue.js实现图片轮播效果

    3. 前后切换按钮,为这些按钮绑定前进后退的方法,以切换图片。 4. 自动播放功能,通过setInterval设置定时器,每隔一定时间就自动切换到下一张图片。 5. 交互动画效果,为轮播图添加鼠标悬停时停止自动播放,再次移...

    jQuery css3商品图片快速查看代码

    在图片快速查看功能中,CSS3的这些特性被用来创建平滑的放大效果、动态切换图片以及调整预览窗口的样式。 1. **事件绑定**:在jQuery中,我们可以使用`$(selector).on('event', callback)`来绑定事件。例如,我们...

    40个非常酷的CSS3动画演示

    3. **方向键控制的3D盒子**:利用键盘事件和3D转换,让3D盒子跟随用户输入转动。 4. **3D盒子滑入/滑出**:通过CSS3的动画和3D转换,实现3D元素的动态显示和隐藏。 5. **CSS3折叠**:元素能够平滑地展开或折叠,增加...

    50 多个使用 HTML、CSS 和 JS 的迷你网络项目

    3D 盒子背景 项目启动者 动画倒计时 为按钮添加了样式 动画导航 自动文本效果 背景滑块 模糊加载 加载模糊 按钮涟漪效果 改变事件 x, y 坐标 内容占位符 自定义范围滑块 双击心形 双垂直滑块 拖放 绘图应用程序 喝水...

Global site tag (gtag.js) - Google Analytics