Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[发布] 首页3D幻灯代码

[复制链接]
阿忠560 发表于 2012-4-30 09:12:35 | 显示全部楼层 |阅读模式
本帖最后由 阿忠560 于 2012-4-30 12:52 编辑

  1. <DIV class=blockcode>
  2. <BLOCKQUOTE><style>
  3. .hpicccccccccc ul {margin:0;padding:0}
  4. .hpicccccccccc{ float:left; overflow:hidden; background-color:#000; padding:3px;}
  5. .hpicccccccccc li {list-style:none}
  6. .hpicccccccccc img {border:none;display:block}
  7. .slide-wp, .hpicccccccccc{ height:438px;}/*幻灯片高,根据你网页需要的大小来调整,不过太小了感觉不到3D效果*/
  8. .nav-wp, .slide-wp, .hpicccccccccc{ width:450px;}/*幻灯片的宽*/
  9. .slide-wp {
  10. overflow: hidden;
  11. position: absolute;
  12. }
  13. .nav-wp {
  14. position: absolute;
  15. background: #000;opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50);
  16. margin-top: 322px;/*按钮所在高度随意调整*/
  17. padding: 0 0 6px 0;
  18. }
  19. .nav li {
  20. float: left;
  21. margin-left: 10px;
  22. font-size: 20px;
  23. font-weight: bold;
  24. font-family: tahoma;
  25. color: #22739e;
  26. cursor: pointer;
  27. height: 22px;
  28. }
  29. .nav li.cur{color: #ff7a00}
  30. .next { float:right;
  31. padding: 4px 8px;
  32. color: #ff7a00;
  33. height: 20px;
  34. cursor: pointer;
  35. }
  36. </style>

  37. <div class="hpicccccccccc">
  38. <div id="slider" class="slide-wp">
  39. <ul>
  40. [loop]
  41. <li><a href="{url}" target="_blank"><img src="{pic}" /></a></li>
  42. [/loop]
  43. </ul>
  44. </div>
  45. <div class="nav-wp">
  46. <ul id="nav" class="nav">
  47. <a class="next" onClick="mySlider.move()"></a>
  48. <li onClick="mySlider.pos(0)">●</li>
  49. <li onClick="mySlider.pos(1)">●</li>
  50. <li onClick="mySlider.pos(2)">●</li>
  51. <li onClick="mySlider.pos(3)">●</li>
  52. <li onClick="mySlider.pos(4)">●</li>
  53. </ul>

  54. </div>
  55. </div>

  56. <script type="text/javascript">
  57. var HR = {
  58. $ : function(i) {return document.getElementById(i)},
  59. $$ : function(c, p) {return p.getElementsByTagName(c)},
  60. ce : function(i, t) {
  61. var o = document.createElement(i);
  62. t.appendChild(o);
  63. return o;
  64. }
  65. };
  66. HR.slider3D = function () {
  67. var init = function (o) {
  68. this.o = o;
  69. var wp = HR.$(o.id), ul = HR.$$('ul', wp)[0], li = this.li = HR.$$('li', ul);
  70. this.l = li.length;
  71. this.w = wp.offsetWidth;
  72. this.h = wp.offsetHeight;
  73. this.at = o.auto? o.auto : 4;
  74. var con = this.con = HR.ce('div', wp);
  75. con.style.cssText = 'position:absolute;left:0;top:0;width:'+this.w+'px;height:'+this.h+'px';
  76. ul.style['display'] = 'none';
  77. this.a1 = HR.ce('a', con);
  78. this.a1.style.cssText = 'position:absolute;left:0;top:0;overflow:hidden';
  79. this.a2 = HR.ce('a', con);
  80. this.a2.style.cssText = 'position:absolute;top:0;right:0;overflow:hidden';
  81. this.a1.innerHTML = this.a2.innerHTML = '<img alt="" />';
  82. this.img = HR.$$('img', ul);
  83. this.s = o.maskSize ? o.maskSize : 5;

  84. this.mask11 = HR.ce('span', this.a1);
  85. this.mask12 = HR.ce('span', this.a1);
  86. this.mask21 = HR.ce('span', this.a2);
  87. this.mask22 = HR.ce('span', this.a2);

  88. this.pos(0);
  89. }
  90. init.prototype = {
  91. pos : function (i) {
  92. clearInterval(this.li[i].a); clearInterval(this.au); this.au = 0; this.cur = i;
  93. var navli = HR.$$('li', HR.$(this.o.navId));
  94. for (var j=0; j<navli.length; j++) {
  95. navli[j].className = i == j ? 'cur' : '';
  96. }
  97. var img1 = HR.$$('img', this.a1)[0], img2 = HR.$$('img', this.a2)[0], _this = this;
  98. img1.src = i==0 ? this.img[this.l-1].src : this.img[i-1].src;
  99. img1.width = this.w;
  100. img2.src = this.img[i].src;
  101. img2.width = 0;
  102. img1.height = img2.height = this.h;
  103. 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';
  104. 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';
  105. 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';
  106. 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';
  107. this.li[i].a = setInterval(function(){_this.anim(i)}, 20);
  108. },
  109. anim : function (i) {
  110. var w1 = HR.$$('img', this.a1)[0].width, w2 = HR.$$('img', this.a2)[0].width;
  111. if (w2 == this.w) {
  112. clearInterval(this.li[i].a);
  113. HR.$$('img', this.a1)[0].width = 0;
  114. HR.$$('img', this.a2)[0].width = this.w;
  115. this.mask11.style.borderLeftWidth = this.mask11.style.borderRightWidth = this.mask12.style.borderLeftWidth = this.mask12.style.borderRightWidth = '0px';
  116. this.mask11.style.borderTopWidth = this.mask11.style.borderBottomWidth = this.mask12.style.borderTopWidth = this.mask12.style.boderBottomWidth = this.h/this.s + 'px';
  117. this.mask21.style.borderLeftWidth = this.mask21.style.borderRightWidth = this.mask22.style.borderLeftWidth = this.mask22.style.bordrRightWidth = this.w/2 + 'px';
  118. this.mask21.style.borderTopWidth = this.mask21.style.borderBottomWidth = this.mask22.style.borderTopWidth = this.mask22.style.borderBottomWidth = '0px';
  119. }else {
  120. HR.$$('img', this.a1)[0].width -= Math.ceil((this.w-w2)*.13);
  121. HR.$$('img', this.a2)[0].width += Math.ceil((this.w-w2)*.13);
  122. this.mask11.style.borderLeftWidth = this.mask11.style.borderRightWidth = this.mask12.style.borderLeftWidth = this.mask12.style.bordightWidth = HR.$$('img', this.a1)[0].width/2 + 'px';
  123. 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';
  124. this.mask21.style.borderLeftWidth = this.mask21.style.borderRightWidth = this.mask22.style.borderLeftWidth = this.mask22.style.borderRightWidth = HR.$$('img', this.a2)[0].width/2 + 'px';
  125. 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';
  126. if (!this.au) this.auto();
  127. }
  128. },
  129. auto : function () {
  130. var _this = this;
  131. this.au = setInterval(function(){_this.move()}, this.at*1000);
  132. },
  133. move : function () {
  134. var n = this.cur==this.l-1 ? 0 : this.cur+1;
  135. this.pos(n);
  136. }
  137. }
  138. return init;
  139. }();
  140. var mySlider = new HR.slider3D({
  141. id: 'slider',
  142. maskSize: 6,
  143. navId: 'nav',
  144. auto: 4
  145. })</script>
复制代码
演示网址:http://www.xinjjr.com/trip/  新晋江人 旅游频道

修改的



时光流逝而去 发表于 2012-4-30 11:52:25 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

a475305268 发表于 2012-4-30 11:56:52 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

hdwjz 发表于 2012-7-5 09:30:55 | 显示全部楼层
新手,研究中。。。
回复

使用道具 举报

oyanan 发表于 2012-7-21 17:48:02 | 显示全部楼层
超级支持一个!
回复

使用道具 举报

wxmvswh 发表于 2012-12-5 02:51:19 | 显示全部楼层
给力啊
回复

使用道具 举报

手心温度 发表于 2013-2-22 11:11:56 | 显示全部楼层
请问下 高和宽哪里设置呢
回复

使用道具 举报

手心温度 发表于 2013-2-22 11:22:49 | 显示全部楼层
高和宽看到了!那个边框黑色的怎么设置?
回复

使用道具 举报

手心温度 发表于 2013-2-22 11:50:56 | 显示全部楼层
左边边距太宽在哪修改呢?
回复

使用道具 举报

厦新情缘 发表于 2013-2-25 20:06:36 | 显示全部楼层
DIY 提示 标签不匹配
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-15 10:32 , Processed in 0.022542 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表