[关闭]
@fantaghiro 2015-02-03T10:43:49.000000Z 字数 43776 阅读 2894

妙味课堂 - 实例

学习笔记 js 前端 妙味课堂


JS分页

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>js分页</title>
  6. <style>
  7. a {margin: 5px;}
  8. </style>
  9. <script>
  10. window.onload = function(){
  11. page({
  12. id : 'div1',
  13. nowNum : 7,
  14. allNum : 10,
  15. callBack : function(now, all){
  16. alert('当前页:' + now + ',总共页:' + all);
  17. }
  18. });
  19. }
  20. function page(opt){
  21. if(!opt.id){return false};
  22. var obj = document.getElementById(opt.id);
  23. var nowNum = opt.nowNum || 1;
  24. var allNum = opt.allNum || 5;
  25. var callBack = opt.callBack || function(){};
  26. if(nowNum >= 4 && allNum >=6){
  27. var oA = document.createElement('a');
  28. oA.href = '#1';
  29. oA.innerHTML = '首页';
  30. obj.appendChild(oA);
  31. }
  32. if(nowNum >=2){
  33. var oA = document.createElement('a');
  34. oA.href = '#' + (nowNum -1);
  35. oA.innerHTML = '上一页';
  36. obj.appendChild(oA);
  37. }
  38. if(allNum <= 5){
  39. for(var i=1; i<=allNum; i++){
  40. var oA = document.createElement('a');
  41. oA.href = '#' + i;
  42. if(nowNum == i){
  43. oA.innerHTML = i;
  44. } else {
  45. oA.innerHTML = '[' + i + ']';
  46. }
  47. obj.appendChild(oA);
  48. }
  49. } else {
  50. for(var i=1; i<=5; i++){
  51. var oA = document.createElement('a');
  52. if(nowNum == 1 || nowNum == 2){
  53. oA.href = '#' + i;
  54. if(nowNum == i){
  55. oA.innerHTML = i;
  56. } else {
  57. oA.innerHTML = '[' + i + ']';
  58. }
  59. } else if((allNum - nowNum) == 0 || (allNum - nowNum) == 1 ){
  60. oA.href = '#' + (allNum - 5 + i);
  61. if((allNum - nowNum) == 0 && i == 5){
  62. oA.innerHTML = (allNum - 5 + i);
  63. } else if ((allNum - nowNum) == 1 && i == 4){
  64. oA.innerHTML = (allNum - 5 + i);
  65. } else {
  66. oA.innerHTML = '[' + (allNum - 5 + i) + ']';
  67. }
  68. } else {
  69. oA.href = '#' + (nowNum - 3 + i);
  70. if(i == 3){
  71. oA.innerHTML = nowNum - 3 + i;
  72. } else {
  73. oA.innerHTML = '[' + (nowNum - 3 + i) + ']';
  74. }
  75. }
  76. obj.appendChild(oA);
  77. }
  78. }
  79. if((allNum - nowNum) >= 1){
  80. var oA = document.createElement('a');
  81. oA.href = '#' + (nowNum + 1);
  82. oA.innerHTML = '下一页';
  83. obj.appendChild(oA);
  84. }
  85. if((allNum - nowNum) >= 3 && allNum >= 6){
  86. var oA = document.createElement('a');
  87. oA.href = '#' + allNum;
  88. oA.innerHTML = '尾页';
  89. obj.appendChild(oA);
  90. }
  91. callBack(nowNum, allNum);
  92. var aA = obj.getElementsByTagName('a');
  93. for(var i=0; i<aA.length; i++){
  94. aA[i].onclick = function(){
  95. var nowNum = parseInt(this.getAttribute('href').substring(1));
  96. obj.innerHTML = '';
  97. page({
  98. id : opt.id,
  99. nowNum : nowNum,
  100. allNum : allNum,
  101. callBack : callBack
  102. })
  103. return false; //阻止默认事件,避免#数字添到地址栏
  104. }
  105. }
  106. }
  107. </script>
  108. </head>
  109. <body>
  110. <div id="div1">
  111. <!-- <a href="#1">首页</a>
  112. <a href="#3">上一页</a>
  113. <a href="#2">[2]</a>
  114. <a href="#3">[3]</a>
  115. <a href="#4">4</a>
  116. <a href="#5">[5]</a>
  117. <a href="#6">[6]</a>
  118. <a href="#5">下一页</a>
  119. <a href="#10">尾页</a> -->
  120. </div>
  121. </body>
  122. </html>

选中文字分享

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>选中分享</title>
  6. <style>
  7. #p1 {width: 300px; margin: 50px;}
  8. #div1 {position: absolute; display: none;}
  9. </style>
  10. <script>
  11. window.onload = function(){
  12. function selectText(){
  13. if(document.selection){ //针对ie
  14. return document.selection.createRange().text; //返回选中的文字
  15. } else { //标准
  16. return window.getSelection().toString();
  17. }
  18. }
  19. var oP = document.getElementById('p1');
  20. var oDiv = document.getElementById('div1');
  21. oP.onmouseup = function(ev){
  22. var ev = ev || window.event;
  23. var left = ev.clientX;
  24. var top = ev.clientY;
  25. if(selectText().length > 10){
  26. setTimeout(function(){
  27. oDiv.style.display = 'block';
  28. oDiv.style.left = left + 'px';
  29. oDiv.style.top = top + 'px';
  30. }, 100);
  31. } else {
  32. oDiv.style.display = 'none';
  33. }
  34. }
  35. oP.onclick = function(ev){
  36. var ev = ev || window.event;
  37. ev.cancelBubble = true;
  38. }
  39. document.onclick = function(){
  40. oDiv.style.display = 'none';
  41. }
  42. oDiv.onclick = function(){
  43. window.location.href = 'http://v.t.sina.com.cn/share/share.php?searchPic=false&title=' + selectText() + '&url=http://www.baidu.com';
  44. }
  45. }
  46. </script>
  47. </head>
  48. <body>
  49. <p id="p1">
  50. 关于腾讯企业邮,你不知道的那些事:一、无需登录邮箱,可用微信直接收发邮件二、邮箱绑定微信,可及时获取新邮件通知三、微信动态密码,可确保邮箱安全不被盗超过40万家公司已经在使用腾讯企业邮,每天超过800家企业正在加入。为了节省您的时间,请您 在线登记,腾讯企业邮团队将为您提供详尽的咨询服务。要了解更多信息,您还可以登录腾讯企业邮官网
  51. </p>
  52. <div id="div1"><img src="img/share.gif" alt=""></div>
  53. </body>
  54. </html>

无缝切换

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>无缝切换</title>
  6. <style>
  7. * {margin: 0; padding: 0;}
  8. li {list-style: none;}
  9. #div1 {width: 350px; height: 60px; border: 1px #000 solid; position: relative; margin: 0 auto; overflow: hidden;}
  10. #div1 ul {position: absolute; left: 0;}
  11. #div1 ul li {width: 80px; height: 60px; margin-right: 10px; float: left;}
  12. img {width: 80px; height: 60px;}
  13. </style>
  14. <script src="move.js"></script>
  15. <script>
  16. window.onload = function(){
  17. var oInput = document.getElementById('input1');
  18. var oUl = document.getElementById('ul1');
  19. var aLi = oUl.getElementsByTagName('li');
  20. var oneSize = aLi[0].offsetWidth + 10; //10是margin
  21. var iNum = 4;
  22. var bBtn = true;
  23. function getWidth(){
  24. oUl.style.width = oneSize * aLi.length + 'px';
  25. }
  26. getWidth();
  27. // 复制节点的方法: cloneNode(boolean) : 如果参数为true,就是一起复制里面的子节点;如果参数为false,就只复制当前节点,不复制里面的子节点。
  28. oInput.onclick = function(){
  29. if(bBtn){
  30. bBtn = false;
  31. for(var i=0; i<iNum; i++){
  32. var oLi = aLi[i].cloneNode(true);
  33. oUl.appendChild(oLi);
  34. getWidth();
  35. }
  36. startMove(oUl, {
  37. left : - iNum * oneSize
  38. }, function(){
  39. for(var i=0; i<iNum; i++){
  40. oUl.removeChild(aLi[0]);
  41. oUl.style.left = 0;
  42. }
  43. bBtn = true;
  44. })
  45. }
  46. }
  47. }
  48. </script>
  49. </head>
  50. <body>
  51. <input type="button" value="切换" id="input1">
  52. <div id="div1">
  53. <ul id="ul1">
  54. <li><img src="photo/1.jpg"></li>
  55. <li><img src="photo/2.jpg"></li>
  56. <li><img src="photo/3.jpg"></li>
  57. <li><img src="photo/4.jpg"></li>
  58. <li><img src="photo/5.jpg"></li>
  59. </ul>
  60. </div>
  61. </body>
  62. </html>

百叶窗效果

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>百叶窗效果</title>
  6. <style>
  7. * {margin: 0; padding: 0;}
  8. li {list-style: none;}
  9. #ul1, #ul2 {width: 300px; height: auto; float: left; border-top: 1px #000 solid; margin: 20px;}
  10. li {width: 100%; height: 30px; overflow: hidden; position: relative; border-bottom: 1px dashed #333; line-height: 30px;}
  11. li div {position: absolute; top: -30px;}
  12. li div p {height: 30px;}
  13. </style>
  14. <script src="move.js"></script>
  15. <script>
  16. window.onload = function(){
  17. var oUl = document.getElementById('ul1');
  18. var oUl2 = document.getElementById('ul2');
  19. toShow(oUl);
  20. setTimeout(function(){
  21. toShow(oUl2);
  22. }, 2000);
  23. function toShow(obj){
  24. var iNow = 0;
  25. var timer = null;
  26. var target = -30;
  27. var aDiv = obj.getElementsByTagName('div');
  28. setInterval(function(){
  29. toChange();
  30. }, 4000);
  31. function toChange(){
  32. target = target == 0 ? -30 : 0;
  33. timer = setInterval(function(){
  34. if(iNow == aDiv.length){
  35. clearInterval(timer);
  36. iNow = 0;
  37. } else {
  38. startMove(aDiv[iNow], {top: target})
  39. iNow++;
  40. }
  41. }, 100);
  42. }
  43. }
  44. }
  45. </script>
  46. </head>
  47. <body>
  48. <ul id="ul1">
  49. <li>
  50. <div>
  51. <p>11111111</p>
  52. <p>22222222</p>
  53. </div>
  54. </li>
  55. <li>
  56. <div>
  57. <p>33333333</p>
  58. <p>44444444</p>
  59. </div>
  60. </li>
  61. <li>
  62. <div>
  63. <p>55555555</p>
  64. <p>66666666</p>
  65. </div>
  66. </li>
  67. <li>
  68. <div>
  69. <p>7777777</p>
  70. <p>8888888</p>
  71. </div>
  72. </li>
  73. <li>
  74. <div>
  75. <p>9999999</p>
  76. <p>8888888</p>
  77. </div>
  78. </li>
  79. <li>
  80. <div>
  81. <p>7777777</p>
  82. <p>6666666</p>
  83. </div>
  84. </li>
  85. </ul>
  86. <ul id="ul2">
  87. <li>
  88. <div>
  89. <p>11111111</p>
  90. <p>22222222</p>
  91. </div>
  92. </li>
  93. <li>
  94. <div>
  95. <p>33333333</p>
  96. <p>44444444</p>
  97. </div>
  98. </li>
  99. <li>
  100. <div>
  101. <p>55555555</p>
  102. <p>66666666</p>
  103. </div>
  104. </li>
  105. <li>
  106. <div>
  107. <p>7777777</p>
  108. <p>8888888</p>
  109. </div>
  110. </li>
  111. <li>
  112. <div>
  113. <p>9999999</p>
  114. <p>8888888</p>
  115. </div>
  116. </li>
  117. <li>
  118. <div>
  119. <p>7777777</p>
  120. <p>6666666</p>
  121. </div>
  122. </li>
  123. </ul>
  124. </body>
  125. </html>

微博发布框

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>微博发布框</title>
  6. <style>
  7. body {font-size: 12px;}
  8. #div1 {width: 400px; margin: 20px auto;}
  9. #div1 p {float: right; margin: 0;}
  10. #div1 textarea {width: 400px; height: 100px;}
  11. #div1 a {width: 50px; height: 30px; font-size: 16px; line-height: 30px; text-align: center; float: right; background: #00ff00; color: #fff;}
  12. #div1 a.dis {background: #cccccc; color; #666}
  13. </style>
  14. <script>
  15. //onchange: 当光标消失的时候,只能触发一次
  16. // ie : onpropertychange : 输入连续触发
  17. // 标准:oninput : 也是连续触发
  18. window.onload = function(){
  19. var oDiv = document.getElementById('div1');
  20. var oP = oDiv.getElementsByTagName('p')[0];
  21. var oT = oDiv.getElementsByTagName('textarea')[0];
  22. var oA = oDiv.getElementsByTagName('a')[0];
  23. var ie = !-[1,];
  24. var bBtn = true;
  25. var timer = null;
  26. var iNum = 0;
  27. oT.onfocus = function(){
  28. if(bBtn){
  29. oP.innerHTML = '打击虚假消息,建设文明微博,还可以输入<span>140</span>字';
  30. bBtn = false;
  31. }
  32. }
  33. oT.onblur = function(){
  34. if(oT.value == ''){
  35. oP.innerHTML = '《新浪微博社区公约(征求意见稿)》意见征求';
  36. bBtn = true;
  37. }
  38. }
  39. /*oT.onchange = function(){
  40. console.log(1);
  41. }*/
  42. if(ie){
  43. oT.onpropertychange = toChange;
  44. } else {
  45. oT.oninput = toChange;
  46. }
  47. function toChange(){
  48. //英文字母算半个字;一个中文算一个字
  49. var num = Math.ceil(getLength(oT.value)/2);
  50. var oSpan = oDiv.getElementsByTagName('span')[0];
  51. if(num <= 140){
  52. oSpan.innerHTML = 140 - num;
  53. oSpan.style.color = '';
  54. } else {
  55. oSpan.innerHTML = num - 140;
  56. oSpan.style.color = 'red';
  57. }
  58. if(oT.value == '' || num > 140){
  59. oA.className = 'dis';
  60. } else {
  61. oA.className = '';
  62. }
  63. }
  64. oA.onclick = function(){
  65. if(this.className == 'dis'){
  66. clearInterval(timer);
  67. timer = setInterval(function(){
  68. if(iNum == 5){
  69. clearInterval(timer);
  70. iNum = 0;
  71. } else {
  72. iNum++;
  73. }
  74. if(iNum%2){
  75. oT.style.background = 'red';
  76. } else {
  77. oT.style.background = '';
  78. }
  79. }, 100);
  80. } else {
  81. alert('发布成功!');
  82. }
  83. }
  84. function getLength(str){
  85. return String(str).replace(/[^\x00-\xff]/g, 'aa').length;
  86. //用正则去匹配中文字符,找到一个中文字符,就用两个字母(比如aa)来替换,这样一个中文汉字就对应了两个字母的长度
  87. //String(str) 不管传进来的参数str是什么,都转成字符串格式
  88. }
  89. }
  90. </script>
  91. </head>
  92. <body>
  93. <div id="div1">
  94. <p>《新浪微博社区公约(征求意见稿)》意见征求</p>
  95. <textarea></textarea>
  96. <a class="dis" href="javascript:">发布</a>
  97. </div>
  98. </body>
  99. </html>

微博登陆

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>微博登陆</title>
  6. <style>
  7. * {margin: 0; padding: 0;}
  8. body {font: 12px/1.125 Arial, Helvetica, sans-serif;}
  9. li {list-style: none;}
  10. #login {width: 252px; height: 385px; background: #BFFFFF; margin: 20px auto; position: relative;}
  11. .detail {margin: 0 0 5px 30px; position: relative; top: 110px;}
  12. .detail input {color: #999; border: 1px solid #74c8e5; border-radius: 3px 3px 3px 3px; height: 15px; line-height: 14px; padding: 8px 5px 7px; width: 184px;}
  13. #suggest {background: none repeat scroll 0 0 #fff; border: 1px solid #ccc; left: 30px; margin: 0; overflow: hidden; padding: 0; position: absolute; text-align: left; top: 142px; visibility: visible; width: 194px; z-index: 1; display: none;}
  14. .note, .item {clear: both; color: #999; cursor: pointer; font-size: 12px; height: 20px; line-height: 20px; list-style: none outside none; margin: 0 1px; padding: 0 5px; white-space: nowrap;}
  15. .active {white-space: nowrap; clear: both; color: rgb(153, 153, 153); cursor: pointer; font-size: 12px; height: 20px; line-height: 20px; list-style: none outside none; margin: 0pt 1px; padding: 0pt 5px; background: none repeat scroll 0% 0% rgb(232, 244, 252);}
  16. </style>
  17. <script>
  18. window.onload = function(){
  19. var s1 = new Suggest();
  20. s1.init(); //初始化程序
  21. }
  22. function Suggest(){
  23. this.oInput = document.getElementById('input1');
  24. this.oUl = document.getElementById('suggest');
  25. this.aLi = this.oUl.getElementsByTagName('li');
  26. }
  27. Suggest.prototype = {
  28. init : function(){
  29. this.toChange();
  30. this.toBlur();
  31. },
  32. toChange : function(){
  33. //ie : onpropertychange
  34. //标准: oninput
  35. var ie = !-[1,];
  36. var This = this;
  37. if(ie){
  38. this.oInput.onpropertychange = function(){
  39. //this.showUl(); this指向不对
  40. if(This.oInput.value == ''){
  41. This.tips();
  42. return;
  43. }
  44. This.showUl();
  45. This.tips();
  46. This.sel(1);
  47. }
  48. } else {
  49. this.oInput.oninput = function(){
  50. This.showUl();
  51. This.tips();
  52. This.sel(1);
  53. }
  54. }
  55. },
  56. showUl : function(){
  57. this.oUl.style.display = 'block';
  58. },
  59. toBlur : function(){
  60. var This = this;
  61. this.oInput.onblur = function(){
  62. This.oUl.style.display = 'none';
  63. }
  64. },
  65. tips : function(){
  66. var value = this.oInput.value;
  67. var re = new RegExp('@' + value.substring(value.indexOf('@')+1) + '');
  68. for(var i=1; i<this.aLi.length; i++){
  69. this.aLi[i].style.display = 'block';
  70. }
  71. if(re.test(value)){
  72. for(var i=1; i<this.aLi.length; i++){
  73. var oEmail = this.aLi[i].getAttribute('email');
  74. if(i==1){
  75. this.aLi[i].innerHTML = value;
  76. } else {
  77. if(re.test(oEmail)){
  78. this.aLi[i].style.display = 'block;'
  79. } else {
  80. this.aLi[i].style.display = 'none';
  81. }
  82. }
  83. }
  84. } else {
  85. for(var i=1; i<this.aLi.length; i++){
  86. var oEmail = this.aLi[i].getAttribute('email');
  87. if(!oEmail){
  88. this.aLi[i].innerHTML = value;
  89. } else {
  90. this.aLi[i].innerHTML = value + oEmail;
  91. }
  92. }
  93. }
  94. },
  95. sel : function(iNow){
  96. var This = this;
  97. for(var i=1; i<this.aLi.length; i++){
  98. this.aLi[i].className = 'item';
  99. }
  100. if(this.oInput.value == ''){
  101. this.aLi[iNow].className = 'item';
  102. } else {
  103. this.aLi[iNow].className = 'active';
  104. }
  105. for(var i=1; i<this.aLi.length; i++){
  106. this.aLi[i].index = i;
  107. this.aLi[i].onmouseover = function(){
  108. for(var i=1; i<This.aLi.length; i++){
  109. This.aLi[i].className = 'item';
  110. }
  111. this.className = 'active';
  112. iNow = this.index;
  113. }
  114. this.aLi[i].onmousedown = function(){
  115. This.oInput.value = this.innerHTML;
  116. }
  117. }
  118. this.oInput.onkeydown = function(ev){
  119. var ev = ev || window.event;
  120. if(ev.keyCode == 38){ //上
  121. if(iNow == 1){
  122. iNow = This.aLi.length-1;
  123. } else {
  124. iNow--;
  125. }
  126. for(var i=1; i<This.aLi.length; i++){
  127. This.aLi[i].className = 'item';
  128. }
  129. This.aLi[iNow].className = 'active';
  130. } else if(ev.keyCode == 40){ //下
  131. if(iNow == This.aLi.length-1){
  132. iNow = 1;
  133. } else {
  134. iNow++;
  135. }
  136. for(var i=1; i<This.aLi.length; i++){
  137. This.aLi[i].className = 'item';
  138. }
  139. This.aLi[iNow].className = 'active';
  140. } else if(ev.keyCode == 13){ //回车
  141. This.oInput.value = This.aLi[iNow].innerHTML;
  142. This.oInput.blur();
  143. }
  144. }
  145. }
  146. }
  147. </script>
  148. </head>
  149. <body>
  150. <div id="login">
  151. <div class="detail">
  152. <input type="text" id="input1" maxlength="128" placeholder="邮箱/会员账号/手机号" autocomplete="off" node-type="loginname" class="name" tabindex="1" name="loginname">
  153. </div>
  154. <div class="detail">
  155. <input type="password" maxlength="24" placeholder="请输入密码" node-type="password" class="pass" tabindex="2" name="password">
  156. </div>
  157. <ul id="suggest">
  158. <li class="note">请选择邮箱类型</li>
  159. <li email="" class="item"></li>
  160. <li email="@sina.com" class="item">@sina.com</li>
  161. <li email="@163.com" class="item">@163.com</li>
  162. <li email="@qq.com" class="item">@qq.com</li>
  163. <li email="@126.com" class="item">@126.com</li>
  164. <li email="@vip.sina.com" class="item">@vip.sina.com</li>
  165. <li email="@sina.cn" class="item">@sina.cn</li>
  166. <li email="@hotmail.com" class="item">@hotmail.com</li>
  167. <li email="@gmail.com" class="item">@gmail.com</li>
  168. <li email="@sohu.com" class="item">@sohu.com</li>
  169. <li email="@yahoo.cn" class="item">@yahoo.cn</li>
  170. <li email="@139.com" class="item">@139.com</li>
  171. <li email="@wo.com.cn" class="item">@wo.com.cn</li>
  172. <li email="@189.cn" class="item">@189.cn</li>
  173. </ul>
  174. </div>
  175. </body>
  176. </html>

网页进度条

基本效果

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>网页进度条</title>
  6. <style>
  7. #progressBox {width: 300px; height: 40px; border: 1px solid #c8c8c8; background: white; position: relative;}
  8. #progressBar {position: absolute; left: 0; top: 0; z-index: 2; height: 40px; width: 100%; line-height: 40px; color: white; text-align: center; font-size: 20px; font-weight: bold; font-family: Georgia; clip: rect(0px, 0, 40px, 0px); background: #00A1F5;}
  9. #progressText {position: absolute; left: 0; top: 0; z-index: 1; width: 100%; height: 40px; line-height: 40px; color: black; text-align: center; font-size: 20px; font-weight: bold; font-family: Georgia;}
  10. </style>
  11. <script>
  12. window.onload = function(){
  13. var iNow = 0;
  14. var timer = setInterval(function(){
  15. if(iNow == 100){
  16. clearInterval(timer);
  17. } else {
  18. iNow += 2;
  19. progressFn(iNow);
  20. }
  21. }, 30);
  22. function progressFn(cent){
  23. var oDiv1 = document.getElementById('progressBox');
  24. var oDiv2 = document.getElementById('progressBar');
  25. var oDiv3 = document.getElementById('progressText');
  26. var allWidth = parseInt(getStyle(oDiv1, 'width'));
  27. oDiv2.innerHTML = cent + '%';
  28. oDiv3.innerHTML = cent + '%';
  29. oDiv2.style.clip = 'rect(0px, ' + cent/100 * allWidth + 'px, 40px, 0px)';
  30. function getStyle(obj, attr){
  31. if(obj.currentStyle){
  32. return obj.currentStyle[attr];
  33. } else {
  34. return getComputedStyle(obj, false)[attr];
  35. }
  36. }
  37. }
  38. }
  39. </script>
  40. </head>
  41. <body>
  42. <div id="progressBox">
  43. <div id="progressBar">0%</div>
  44. <div id="progressText">0%</div>
  45. </div>
  46. </body>
  47. </html>

反映真实数据的进度条
- 硬编码 : 写死的数据
- 跟flash配合 : as3
- html5 : xhr 2: onprogress事件 onload事件
- 跟后台的配合 : ajax的实时返回数据

硬编码的进度条效果

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <style>
  7. * {margin: 0; padding: 0;}
  8. #progressBox {width: 300px; height: 40px; border: 1px solid #c8c8c8; background: white; position: relative;}
  9. #progressBar {position: absolute; left: 0; top: 0; z-index: 2; height: 40px; width: 100%; line-height: 40px; color: white; text-align: center; font-size: 20px; font-weight: bold; font-family: Georgia; clip: rect(0px, 0, 40px, 0px); background: #00A1F5;}
  10. #progressText {position: absolute; left: 0; top: 0; z-index: 1; width: 100%; height: 40px; line-height: 40px; color: black; text-align: center; font-size: 20px; font-weight: bold; font-family: Georgia;}
  11. </style>
  12. </head>
  13. <body>
  14. <div id="progressBox">
  15. <div id="progressBar">0%</div>
  16. <div id="progressText">0%</div>
  17. </div>
  18. <div id="div2" style="display: none;">
  19. <img src="http://images.wisegeek.com/young-calico-cat.jpg" >
  20. <img src="http://images.wisegeek.com/lint-roller-against-green-shirt.jpg">
  21. <img src="http://images.wisegeek.com/girl-holding-cat-in-hand-while-blowing-nose.jpg">
  22. <img src="http://images.wisegeek.com/woman-vacuuming.jpg">
  23. <img src="http://images.wisegeek.com/cat-shedding.jpg">
  24. <img src="http://images.wisegeek.com/pet-comb.jpg">
  25. <img src="http://images.wisegeek.com/young-goat-on-a-grass-field.jpg">
  26. </div>
  27. <script>
  28. //硬编码:写死的数据。加载一幅图片就前进1/7的进度
  29. var oDiv2 = document.getElementById('div2');
  30. var aImg = oDiv2.getElementsByTagName('img');
  31. var oDiv1 = document.getElementById('progressBox');
  32. var iNow = 0;
  33. for(var i=0; i<aImg.length; i++){
  34. (function(i){
  35. var yImg = new Image();
  36. yImg.onload = function(){
  37. iNow++;
  38. progressFn(parseInt(iNow/aImg.length * 100));
  39. if(iNow == aImg.length){
  40. oDiv2.style.display = 'block';
  41. oDiv1.style.display = 'none';
  42. }
  43. }
  44. yImg.src = aImg[i].src;
  45. })(i);
  46. }
  47. function progressFn(cent){
  48. var oDiv1 = document.getElementById('progressBox');
  49. var oDiv2 = document.getElementById('progressBar');
  50. var oDiv3 = document.getElementById('progressText');
  51. var allWidth = parseInt(getStyle(oDiv1, 'width'));
  52. oDiv2.innerHTML = cent + '%';
  53. oDiv3.innerHTML = cent + '%';
  54. oDiv2.style.clip = 'rect(0px, ' + cent/100 * allWidth + 'px, 40px, 0px)';
  55. function getStyle(obj, attr){
  56. if(obj.currentStyle){
  57. return obj.currentStyle[attr];
  58. } else {
  59. return getComputedStyle(obj, false)[attr];
  60. }
  61. }
  62. }
  63. </script>
  64. </body>
  65. </html>

数码时钟

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>数码时钟</title>
  6. <style>
  7. body {background: #eee; color: white; font-size: 30px;}
  8. #div1 {width: 300px; height: 36px; border: 1px #fff solid;}
  9. #div1 img {width: 25px; height: 36px; position: relative;}
  10. </style>
  11. <script>
  12. window.onload = function(){
  13. var aImg = document.getElementsByTagName('img');
  14. var oDate = new Date();
  15. var prevStr = toZero(oDate.getHours()) + toZero(oDate.getMinutes()) + toZero(oDate.getSeconds());
  16. var nextStr = '';
  17. var arr = [];
  18. var timer = null;
  19. for(var i=0; i<aImg.length; i++){
  20. aImg[i].src = 'img/' + prevStr.charAt(i) + '.png';
  21. }
  22. setInterval(toChange, 1000);
  23. function toChange(){
  24. var oDate = new Date();
  25. nextStr = toZero(oDate.getHours()) + toZero(oDate.getMinutes()) + toZero(oDate.getSeconds());
  26. /*console.log(prevStr);
  27. console.log(nextStr);*/
  28. toCom(prevStr, nextStr);
  29. prevStr = nextStr;
  30. }
  31. function toCom(str1, str2){
  32. arr = [];
  33. for(var i=0; i<str1.length; i++){
  34. if(str1.charAt(i) != str2.charAt(i)){
  35. arr.push(i);
  36. }
  37. }
  38. startMove();
  39. }
  40. function startMove(){
  41. var iSpeed = -4;
  42. timer = setInterval(function(){
  43. for(var i=0; i<arr.length; i++){
  44. if(aImg[arr[i]].offsetHeight == 0){
  45. iSpeed = 4;
  46. aImg[arr[i]].src = 'img/' + nextStr.charAt(arr[i]) + '.png';
  47. }
  48. aImg[arr[i]].style.height = aImg[arr[i]].offsetHeight + iSpeed + 'px';
  49. aImg[arr[i]].style.top = aImg[arr[i]].offsetHeight/2 - 18 + 'px';
  50. if(aImg[arr[i]].offsetHeight == 36){
  51. clearInterval(timer);
  52. }
  53. }
  54. }, 10)
  55. }
  56. function toZero(num){
  57. if(num < 10){
  58. return '0' + num;
  59. } else {
  60. return '' + num;
  61. }
  62. }
  63. }
  64. </script>
  65. </head>
  66. <body>
  67. <div id="div1">
  68. <img src="img/0.png">
  69. <img src="img/0.png">:
  70. <img src="img/0.png">
  71. <img src="img/0.png">:
  72. <img src="img/0.png">
  73. <img src="img/0.png">
  74. </div>
  75. </body>
  76. </html>

老版官网分页特效

请参照JS分页实例来看

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>js分页</title>
  6. <style>
  7. * {margin: 0; padding: 0;}
  8. li {list-style: none;}
  9. #ul1 {width: 600px; height: 250px;}
  10. #ul1 li {width: 100px; height: 100px; background: red; float: left; overflow: hidden; margin: 10px;}
  11. a {margin: 5px;}
  12. </style>
  13. <script src="move.js"></script>
  14. <script>
  15. window.onload = function(){
  16. var json = {
  17. title: [
  18. '效果1',
  19. '效果2',
  20. '效果3',
  21. '效果4',
  22. '效果5',
  23. '效果6',
  24. '效果7',
  25. '效果8',
  26. '效果9',
  27. '效果10',
  28. '效果11',
  29. '效果12',
  30. '效果13',
  31. '效果14',
  32. '效果15',
  33. '效果16',
  34. '效果17',
  35. '效果18',
  36. '效果19',
  37. '效果20',
  38. '效果21',
  39. '效果22',
  40. '效果23',
  41. '效果24',
  42. '效果25',
  43. '效果26',
  44. '效果27',
  45. '效果28',
  46. '效果29',
  47. '效果30',
  48. '效果31',
  49. '效果32',
  50. '效果33',
  51. '效果34'
  52. ]
  53. }
  54. var arr = [];
  55. var iNow = 9;
  56. page({
  57. id : 'div1',
  58. nowNum : 1,
  59. allNum : Math.ceil(json.title.length/10),
  60. callBack : function(now, all){
  61. var num = now * 10 < json.title.length ? 10 : json.title.length - (now-1)*10;
  62. var oUl = document.getElementById('ul1');
  63. var aLi = oUl.getElementsByTagName('li');
  64. if(oUl.innerHTML == ''){
  65. for(var i=0; i<num; i++){
  66. var oLi = document.createElement('li');
  67. oLi.innerHTML = json.title[(now-1)*10 + i];
  68. oUl.appendChild(oLi);
  69. }
  70. for(var i=0; i<aLi.length; i++){
  71. arr.push([aLi[i].offsetLeft, aLi[i].offsetTop]);
  72. }
  73. for(var i=0; i<aLi.length; i++){
  74. aLi[i].style.position = 'absolute';
  75. aLi[i].style.left = arr[i][0] + 'px';
  76. aLi[i].style.top = arr[i][1] + 'px';
  77. aLi[i].style.margin = '0'
  78. }
  79. } else {
  80. var timer = setInterval(function(){
  81. startMove(aLi[iNow], {left: 200, top: 250, opacity: 0});
  82. if(iNow == 0){
  83. clearInterval(timer);
  84. iNow = num - 1;
  85. for(var i=0; i<num; i++){
  86. aLi[i].innerHTML = json.title[(now-1)*10 + i];
  87. }
  88. var timer2 = setInterval(function(){
  89. startMove(aLi[iNow], {left: arr[iNow][0], top: arr[iNow][1], opacity: 100});
  90. if(iNow == 0){
  91. clearInterval(timer2);
  92. iNow = num - 1;
  93. } else {
  94. iNow--;
  95. }
  96. }, 100);
  97. } else {
  98. iNow--;
  99. }
  100. }, 100);
  101. }
  102. }
  103. });
  104. }
  105. function page(opt){
  106. if(!opt.id){return false};
  107. var obj = document.getElementById(opt.id);
  108. var nowNum = opt.nowNum || 1;
  109. var allNum = opt.allNum || 5;
  110. var callBack = opt.callBack || function(){};
  111. if(nowNum >= 4 && allNum >=6){
  112. var oA = document.createElement('a');
  113. oA.href = '#1';
  114. oA.innerHTML = '首页';
  115. obj.appendChild(oA);
  116. }
  117. if(nowNum >=2){
  118. var oA = document.createElement('a');
  119. oA.href = '#' + (nowNum -1);
  120. oA.innerHTML = '上一页';
  121. obj.appendChild(oA);
  122. }
  123. if(allNum <= 5){
  124. for(var i=1; i<=allNum; i++){
  125. var oA = document.createElement('a');
  126. oA.href = '#' + i;
  127. if(nowNum == i){
  128. oA.innerHTML = i;
  129. } else {
  130. oA.innerHTML = '[' + i + ']';
  131. }
  132. obj.appendChild(oA);
  133. }
  134. } else {
  135. for(var i=1; i<=5; i++){
  136. var oA = document.createElement('a');
  137. if(nowNum == 1 || nowNum == 2){
  138. oA.href = '#' + i;
  139. if(nowNum == i){
  140. oA.innerHTML = i;
  141. } else {
  142. oA.innerHTML = '[' + i + ']';
  143. }
  144. } else if((allNum - nowNum) == 0 || (allNum - nowNum) == 1 ){
  145. oA.href = '#' + (allNum - 5 + i);
  146. if((allNum - nowNum) == 0 && i == 5){
  147. oA.innerHTML = (allNum - 5 + i);
  148. } else if ((allNum - nowNum) == 1 && i == 4){
  149. oA.innerHTML = (allNum - 5 + i);
  150. } else {
  151. oA.innerHTML = '[' + (allNum - 5 + i) + ']';
  152. }
  153. } else {
  154. oA.href = '#' + (nowNum - 3 + i);
  155. if(i == 3){
  156. oA.innerHTML = nowNum - 3 + i;
  157. } else {
  158. oA.innerHTML = '[' + (nowNum - 3 + i) + ']';
  159. }
  160. }
  161. obj.appendChild(oA);
  162. }
  163. }
  164. if((allNum - nowNum) >= 1){
  165. var oA = document.createElement('a');
  166. oA.href = '#' + (nowNum + 1);
  167. oA.innerHTML = '下一页';
  168. obj.appendChild(oA);
  169. }
  170. if((allNum - nowNum) >= 3 && allNum >= 6){
  171. var oA = document.createElement('a');
  172. oA.href = '#' + allNum;
  173. oA.innerHTML = '尾页';
  174. obj.appendChild(oA);
  175. }
  176. callBack(nowNum, allNum);
  177. var aA = obj.getElementsByTagName('a');
  178. for(var i=0; i<aA.length; i++){
  179. aA[i].onclick = function(){
  180. var nowNum = parseInt(this.getAttribute('href').substring(1));
  181. obj.innerHTML = '';
  182. page({
  183. id : opt.id,
  184. nowNum : nowNum,
  185. allNum : allNum,
  186. callBack : callBack
  187. })
  188. return false; //阻止默认事件,避免#数字添到地址栏
  189. }
  190. }
  191. }
  192. </script>
  193. </head>
  194. <body>
  195. <ul id="ul1"></ul>
  196. <div id="div1">
  197. <!-- <a href="#1">首页</a>
  198. <a href="#3">上一页</a>
  199. <a href="#2">[2]</a>
  200. <a href="#3">[3]</a>
  201. <a href="#4">4</a>
  202. <a href="#5">[5]</a>
  203. <a href="#6">[6]</a>
  204. <a href="#5">下一页</a>
  205. <a href="#10">尾页</a> -->
  206. </div>
  207. </body>
  208. </html>

基于对象的联动菜单

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>联动下拉菜单</title>
  6. <script>
  7. window.onload = function(){
  8. var s1 = new Sel('div1');
  9. s1.add('0', ['1', '2', '3']);
  10. s1.add('0_0', ['1_1', '1_2', '1_3']);
  11. s1.add('0_0_0', ['1_1_1', '1_1_2', '1_1_3']);
  12. s1.add('0_0_1', ['1_2_1', '1_2_2', '1_2_3']);
  13. s1.add('0_0_2', ['1_3_1', '1_3_2', '1_3_3']);
  14. s1.add('0_1', ['2_1', '2_2', '2_3']);
  15. s1.add('0_1_0', ['2_1_1', '2_1_2', '2_1_3']);
  16. s1.add('0_1_1', ['2_2_1', '2_2_2', '2_2_3']);
  17. s1.add('0_1_2', ['2_3_1', '2_3_2', '2_3_3']);
  18. s1.add('0_2', ['3_1', '3_2', '3_3']);
  19. s1.add('0_2_0', ['3_1_1', '3_1_2', '3_1_3']);
  20. s1.add('0_2_1', ['3_2_1', '3_2_2', '3_2_3']);
  21. s1.add('0_2_2', ['3_3_1', '3_3_2', '3_3_3']);
  22. s1.init(3);
  23. }
  24. function Sel(id){
  25. this.oParent = document.getElementById(id);
  26. this.data = {};
  27. this.aSel = this.oParent.getElementsByTagName('select');
  28. }
  29. Sel.prototype = {
  30. init: function(num){
  31. var This = this;
  32. for(var i=1; i<=num; i++){
  33. var oSel = document.createElement('select');
  34. var oPt = document.createElement('option');
  35. oPt.innerHTML = '默认';
  36. oSel.appendChild(oPt);
  37. oSel.index = i;
  38. this.oParent.appendChild(oSel);
  39. oSel.onchange = function(){
  40. This.change(this.index);
  41. }
  42. }
  43. this.first();
  44. },
  45. add: function(key, value){
  46. this.data[key] = value;
  47. },
  48. first: function(){
  49. var arr = this.data['0'];
  50. for(var i=0; i<arr.length; i++){
  51. var oPt = document.createElement('option');
  52. oPt.innerHTML = arr[i];
  53. this.aSel[0].appendChild(oPt);
  54. }
  55. },
  56. change: function(iNow){
  57. var str = '0';
  58. for(var i=0; i<iNow; i++){
  59. str += '_' + (this.aSel[i].selectedIndex - 1);
  60. }
  61. if(this.data[str]){
  62. var arr = this.data[str];
  63. this.aSel[iNow].options.length = 1;
  64. for(var i=0; i<arr.length; i++){
  65. var oPt = document.createElement('option');
  66. oPt.innerHTML = arr[i];
  67. this.aSel[iNow].appendChild(oPt);
  68. }
  69. this.aSel[iNow].options[1].selected = true;
  70. //以下是个递归
  71. iNow++;
  72. if(iNow < this.aSel.length){
  73. this.change(iNow);
  74. }
  75. } else {
  76. if(iNow < this.aSel.length){
  77. this.aSel[iNow].options.length = 1;
  78. }
  79. }
  80. }
  81. }
  82. </script>
  83. </head>
  84. <body>
  85. <div id="div1"></div>
  86. </body>
  87. </html>

韩雪冬轮播图

简单的数字切换

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>韩雪冬轮播图</title>
  6. <script>
  7. window.onload = function(){
  8. var oDiv = document.getElementById('div1');
  9. var oInput = document.getElementById('input1');
  10. oInput.onclick = function(){
  11. var arr = oDiv.innerHTML.split(',');
  12. arr.push(arr[0]);
  13. arr.shift();
  14. oDiv.innerHTML = arr;
  15. }
  16. }
  17. </script>
  18. </head>
  19. <body>
  20. <div id="div1">1,2,3,4</div>
  21. <input type="button" value="切换" id="input1">
  22. </body>
  23. </html>

三个div进行切换

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>韩雪冬轮播图</title>
  6. <style>
  7. .box1 {width: 100px; height: 100px; background: red; position: absolute; left: 100px; top: 100px;}
  8. .box2 {width: 100px; height: 100px; background: yellow; position: absolute; left: 250px; top: 50px;}
  9. .box3 {width: 100px; height: 100px; background: blue; position: absolute; left: 400px; top: 100px;}
  10. </style>
  11. <script>
  12. window.onload = function(){
  13. var aInput = document.getElementsByTagName('input');
  14. var aDiv = document.getElementsByTagName('div');
  15. var arr = [];
  16. for(var i=0; i<aDiv.length; i++){
  17. arr.push([getStyle(aDiv[i], 'left'), getStyle(aDiv[i], 'top')]);
  18. }
  19. // console.log(arr);
  20. aInput[0].onclick = function(){
  21. arr.push(arr[0]);
  22. arr.shift();
  23. for(var i=0; i<aDiv.length; i++){
  24. aDiv[i].style.left = arr[i][0];
  25. aDiv[i].style.top = arr[i][1];
  26. }
  27. }
  28. aInput[1].onclick = function(){
  29. arr.unshift(arr[arr.length-1]);
  30. arr.pop();
  31. for(var i=0; i<aDiv.length; i++){
  32. aDiv[i].style.left = arr[i][0];
  33. aDiv[i].style.top = arr[i][1];
  34. }
  35. }
  36. function getStyle(obj, attr){
  37. if(obj.currentStyle){
  38. return obj.currentStyle[attr];
  39. } else {
  40. return getComputedStyle(obj, false)[attr];
  41. }
  42. }
  43. }
  44. </script>
  45. </head>
  46. <body>
  47. <input type="button" value="←">
  48. <input type="button" value="→">
  49. <div class="box1"></div>
  50. <div class="box2"></div>
  51. <div class="box3"></div>
  52. </body>
  53. </html>

妙味官网的演示效果

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>韩雪冬网站效果 - 妙味课堂 - www.miaov.com</title>
  6. <!--[if lte IE 6]>
  7. <script src="js/DD_belatedPNG_0.0.8a.js" type="text/javascript"></script>
  8. <script type="text/javascript">
  9. DD_belatedPNG.fix('span');
  10. </script>
  11. <![endif]-->
  12. <script type="text/javascript" src="miaov.js"></script>
  13. <link href="style.css" rel="stylesheet" type="text/css" />
  14. </head>
  15. <body>
  16. <div id="automatic">
  17. <div class="prev_div"></div>
  18. <a class="prev" href="###">
  19. <span class="ico1"></span>
  20. <span class="ico"></span>
  21. <span class="txt"></span>
  22. </a>
  23. <div class="next_div"></div>
  24. <a class="next" href="###">
  25. <span class="ico1"></span>
  26. <span class="ico"></span>
  27. <span class="txt"></span>
  28. </a>
  29. <div class="line"></div>
  30. <ul>
  31. <li class="pos_0"><a href="http://www.miaov.com"><img src="images/8.jpg" width="100" alt="妙味课堂 www.miaov.com" longdesc="http://www.miaov.com" /></a></li>
  32. <li class="pos_1"><a href="http://www.miaov.com"><img src="images/1.jpg" width="270" alt="妙味课堂 www.miaov.com" longdesc="http://www.miaov.com" /></a></li>
  33. <li class="pos_2"><a href="http://www.miaov.com"><img src="images/2.jpg" width="510" alt="妙味课堂 www.miaov.com" longdesc="http://www.miaov.com" /></a></li>
  34. <li class="pos_3"><a href="http://www.miaov.com"><img src="images/3.jpg" width="680" alt="妙味课堂 www.miaov.com" longdesc="http://www.miaov.com" /></a></li>
  35. <li class="pos_4"><a href="http://www.miaov.com"><img src="images/4.jpg" width="510" alt="妙味课堂 www.miaov.com" longdesc="http://www.miaov.com" /></a></li>
  36. <li class="pos_5"><a href="http://www.miaov.com"><img src="images/5.jpg" width="270" alt="妙味课堂 www.miaov.com" longdesc="http://www.miaov.com" /></a></li>
  37. <li class="pos_6"><a href="http://www.miaov.com"><img src="images/6.jpg" width="270" alt="妙味课堂 www.miaov.com" longdesc="http://www.miaov.com" /></a></li>
  38. <li class="pos_6"><a href="http://www.miaov.com"><img src="images/7.jpg" width="270" alt="妙味课堂 www.miaov.com" longdesc="http://www.miaov.com" /></a></li>
  39. </ul>
  40. </div>
  41. <p id="footer"><a href="http://www.miaov.com">妙味课堂 - www.miaov.com</a></p>
  42. </body>
  43. </html>
  1. @charset "utf-8";
  2. /* CSS Document */
  3. * { padding: 0; margin: 0; }
  4. li { list-style: none; }
  5. img { border: none; }
  6. body { background: #ececec; padding-top: 50px; }
  7. #automatic { width: 970px; height: 344px; position: relative; margin: 0 auto; overflow: hidden; }
  8. .prev_div { width: 130px; height: 72px; position: absolute; top: 128px; left: 92px; z-index: 5; background: red; filter: alpha(opacity=0); opacity: 0; cursor: pointer; }
  9. .next_div { width: 130px; height: 72px; position: absolute; top: 128px; right: 92px; z-index: 5; background: red; filter: alpha(opacity=0); opacity: 0; cursor: pointer; }
  10. #automatic .prev { width: 120px; height: 72px; position: absolute; top: 108px; left: 72px; z-index: 4; }
  11. #automatic .prev .ico { width: 76px; height: 112px; position: absolute; top: 0; left: 0; background: url(images/prev.png); }
  12. #automatic .prev .ico1 { width: 76px; height: 112px; position: absolute; top: 0; left: 0; background: url(images/prev_1.png); z-index: 2; filter: alpha(opacity=0); opacity: 0; }
  13. #automatic .prev .txt { width: 106px; height: 112px; position: absolute; top: 0; left: 65px; background: url(images/prev_txt.png) no-repeat; filter: alpha(opacity=0); opacity: 0; }
  14. #automatic .next { width: 120px; height: 72px; position: absolute; top: 108px; right: 72px; z-index: 4; }
  15. #automatic .next .ico { width: 76px; height: 112px; position: absolute; top: 0; right: 0; background: url(images/next.png) no-repeat; }
  16. #automatic .next .ico1 { width: 76px; height: 112px; position: absolute; top: 0; right: 0px; background: url(images/next_1.png) no-repeat; z-index: 2; filter: alpha(opacity=0); opacity: 0; }
  17. #automatic .next .txt { width: 106px; height: 112px; position: absolute; top: 0; right: 65px; background: url(images/next_txt.png) no-repeat; filter: alpha(opacity=0); opacity: 0; }
  18. #automatic ul { width: 970px; height: 344px; position: absolute; top: 0; left: 0; z-index: 1; }
  19. #automatic li { position: absolute; }
  20. #automatic .line { border: 4px solid #fff; width: 672px; height: 336px; position: absolute; top: 0; left: 50%; margin-left: -340px; z-index: 3; }
  21. #automatic .pos_0 { top: -104px; left: 0; z-index: 1; filter: alpha(opacity=0); opacity: 0; }
  22. #automatic .pos_1 { top: 104px; left: 0; z-index: 2; filter: alpha(opacity=60); opacity: 0.6; }
  23. #automatic .pos_2 { top: 43px; left: 50px; z-index: 3; filter: alpha(opacity=80); opacity: 0.8; }
  24. #automatic .pos_3 { top: 0; left: 145px; z-index: 4; }
  25. #automatic .pos_4 { top: 43px; right: 50px; z-index: 3; filter: alpha(opacity=80); opacity: 0.8; }
  26. #automatic .pos_5 { top: 104px; right: 0; z-index: 2; filter: alpha(opacity=60); opacity: 0.6; }
  27. #automatic .pos_6 { top: -104px; right: 0; z-index: 1; filter: alpha(opacity=0); opacity: 0; }
  28. #footer { width: 970px; height: 30px; text-align: center; padding-top: 50px; margin: 0 auto; }
  29. #footer a { color: #930; font-family: arial; font-size: 15px; text-decoration: none; border-bottom: 1px dotted #930; }
  30. #footer a:hover { border-bottom: 1px solid #930; }
  1. function getElementsByClassName(oParent, sClass)
  2. {
  3. var aTmp=oParent.getElementsByTagName('*');
  4. var aResult=[];
  5. var i=0;
  6. for(i=0;i<aTmp.length;i++)
  7. {
  8. if(aTmp[i].className==sClass)
  9. {
  10. aResult.push(aTmp[i]);
  11. }
  12. }
  13. return aResult;
  14. }
  15. window.onload=function ()
  16. {
  17. var oDiv=document.getElementById('automatic');
  18. var oPrevMask=getElementsByClassName(oDiv,'prev_div')[0];
  19. var oNextMask=getElementsByClassName(oDiv,'next_div')[0];
  20. var oPrevBtn=getElementsByClassName(oDiv,'prev')[0];
  21. var oNextBtn=getElementsByClassName(oDiv,'next')[0];
  22. var oPrevArrow=getElementsByClassName(oPrevBtn,'ico')[0];
  23. var oPrevArrowLight=getElementsByClassName(oPrevBtn,'ico1')[0];
  24. var oPrevTxt=getElementsByClassName(oPrevBtn,'txt')[0];
  25. var oNextArrow=getElementsByClassName(oNextBtn,'ico')[0];
  26. var oNextArrowLight=getElementsByClassName(oNextBtn,'ico1')[0];
  27. var oNextTxt=getElementsByClassName(oNextBtn,'txt')[0];
  28. oPrevArrow.alpha=100;
  29. var iInitPrevArrow=oPrevArrow.left=oPrevArrow.offsetLeft;
  30. oPrevArrowLight.alpha=0;
  31. var iInitPrevArrowLight=oPrevArrowLight.left=oPrevArrowLight.offsetLeft;
  32. oPrevTxt.alpha=0;
  33. var iInitPrevTxt=oPrevTxt.left=oPrevTxt.offsetLeft;
  34. oNextArrow.alpha=100;
  35. var iInitNextArrow=oNextArrow.left=oNextArrow.offsetLeft;
  36. oNextArrowLight.alpha=0;
  37. var iInitNextArrowLight=oNextArrowLight.left=oNextArrowLight.offsetLeft;
  38. oNextTxt.alpha=0;
  39. var iInitNextTxt=oNextTxt.left=oNextTxt.offsetLeft;
  40. var aLi=oDiv.getElementsByTagName('ul')[0].getElementsByTagName('li');
  41. var aLiInit=[];
  42. var oLine=getElementsByClassName(oDiv, 'line')[0];
  43. var iInterval=150;
  44. //var bIsIE=(/msie/i).test(window.navigator.userAgent);
  45. var i=0;
  46. for(i=0;i<aLi.length;i++)
  47. {
  48. aLiInit[i]={};
  49. aLi[i].width=aLiInit[i].w=aLi[i].getElementsByTagName('img')[0].offsetWidth;
  50. aLi[i].height=aLiInit[i].h=aLi[i].getElementsByTagName('img')[0].offsetHeight;
  51. aLi[i].left=aLiInit[i].l=aLi[i].offsetLeft;
  52. aLi[i].top=aLiInit[i].t=aLi[i].offsetTop;
  53. aLi[i].alpha=aLiInit[i].alpha=0;
  54. aLi[i].z=aLiInit[i].z=1;
  55. }
  56. for(i=0;i<aLi.length;i++)
  57. {
  58. aLi[i].style.position='absolute';
  59. aLi[i].style.left=aLiInit[i].l+'px';
  60. aLi[i].style.top=aLiInit[i].t+'px';
  61. }
  62. aLi[1].alpha=aLiInit[1].alpha=60;
  63. aLi[2].alpha=aLiInit[2].alpha=80;
  64. aLi[3].alpha=aLiInit[3].alpha=100;
  65. aLi[4].alpha=aLiInit[4].alpha=80;
  66. aLi[5].alpha=aLiInit[5].alpha=60;
  67. aLi[1].z=aLiInit[1].z=2;
  68. aLi[2].z=aLiInit[2].z=3;
  69. aLi[3].z=aLiInit[3].z=4;
  70. aLi[4].z=aLiInit[4].z=3;
  71. aLi[5].z=aLiInit[5].z=2;
  72. /*if(bIsIE)
  73. {
  74. oPrevArrowLight.style.display='none';
  75. oPrevArrow.style.display='block';
  76. }*/
  77. oPrevMask.onmouseover=function ()
  78. {
  79. /*if(bIsIE)
  80. {
  81. startMove(oPrevArrow, {left: iInitPrevArrow+10}, iInterval);
  82. startMove(oPrevTxt, {left: iInitPrevTxt-10, alpha:100}, iInterval);
  83. }
  84. else
  85. {
  86. startMove(oPrevArrow, {left: iInitPrevArrow+10}, iInterval);
  87. startMove(oPrevArrowLight, {left: iInitPrevArrowLight+10, alpha:100}, iInterval);
  88. startMove(oPrevTxt, {left: iInitPrevTxt-10, alpha:100}, iInterval);
  89. }*/
  90. startMove(oPrevArrow, {left: iInitPrevArrow+10}, iInterval);
  91. startMove(oPrevArrowLight, {left: iInitPrevArrowLight+10, alpha:100}, iInterval);
  92. startMove(oPrevTxt, {left: iInitPrevTxt-10, alpha:100}, iInterval);
  93. };
  94. oPrevMask.onmouseout=function ()
  95. {
  96. /*if(bIsIE)
  97. {
  98. startMove(oPrevArrow, {left: iInitPrevArrow}, iInterval);
  99. startMove(oPrevTxt, {left: iInitPrevTxt, alpha:0}, iInterval);
  100. }
  101. else
  102. {
  103. startMove(oPrevArrow, {left: iInitPrevArrow}, iInterval);
  104. startMove(oPrevArrowLight, {left: iInitPrevArrowLight, alpha:0}, iInterval);
  105. startMove(oPrevTxt, {left: iInitPrevTxt, alpha:0}, iInterval);
  106. }*/
  107. startMove(oPrevArrow, {left: iInitPrevArrow}, iInterval);
  108. startMove(oPrevArrowLight, {left: iInitPrevArrowLight, alpha:0}, iInterval);
  109. startMove(oPrevTxt, {left: iInitPrevTxt, alpha:0}, iInterval);
  110. };
  111. oPrevMask.onmousedown=function ()
  112. {
  113. gotoImg(true);
  114. };
  115. oNextMask.onmouseover=function ()
  116. {
  117. startMove(oNextArrow, {left: iInitNextArrow-10}, iInterval);
  118. startMove(oNextArrowLight, {left: iInitNextArrowLight-10, alpha:100}, iInterval);
  119. startMove(oNextTxt, {left: iInitNextTxt+10, alpha:100}, iInterval);
  120. };
  121. oNextMask.onmouseout=function ()
  122. {
  123. startMove(oNextArrow, {left: iInitNextArrow}, iInterval);
  124. startMove(oNextArrowLight, {left: iInitNextArrowLight, alpha:0}, iInterval);
  125. startMove(oNextTxt, {left: iInitNextTxt, alpha:0}, iInterval);
  126. };
  127. oNextMask.onmousedown=function ()
  128. {
  129. gotoImg(false);
  130. };
  131. function gotoImg(bLeft)
  132. {
  133. if(bLeft)
  134. {
  135. aLiInit.push(aLiInit.shift());
  136. }
  137. else
  138. {
  139. aLiInit.unshift(aLiInit.pop());
  140. }
  141. oLine.style.display='none';
  142. for(i=0;i<aLi.length;i++)
  143. {
  144. startMove(aLi[i], {left: aLiInit[i].l, top: aLiInit[i].t, width: aLiInit[i].w, height:aLiInit[i].h, alpha:aLiInit[i].alpha, zIndex:aLiInit[i].z}, 300, function (){oLine.style.display='block';});
  145. }
  146. };
  147. };
  148. function startMove(obj, oParams, iTime, fnCallBackEnd)
  149. {
  150. var iInterval=45;
  151. var iEndTime=(new Date()).getTime()+iTime;
  152. var iTimes=Math.ceil(iTime/iInterval);
  153. var oSpeed={};
  154. if(typeof obj.timer=='undefined')
  155. {
  156. obj.timer=null;
  157. }
  158. for(key in oParams)
  159. {
  160. oSpeed[key]=(oParams[key]-obj[key])/iTimes;
  161. }
  162. if(obj.timer)
  163. {
  164. clearInterval(obj.timer);
  165. }
  166. obj.timer=setInterval
  167. (
  168. function ()
  169. {
  170. doMove(obj, oParams, oSpeed, iEndTime, fnCallBackEnd);
  171. }, iInterval
  172. );
  173. }
  174. function doMove(obj, oTarget, oSpeed, iEndTime, fnCallBackEnd)
  175. {
  176. var iNow=(new Date()).getTime();
  177. if(iNow>=iEndTime)
  178. {
  179. clearInterval(obj.timer);
  180. obj.timer=null;
  181. for(key in oTarget)
  182. {
  183. obj[key]=oTarget[key];
  184. // alert('set '+key+'='+oTarget[key]);
  185. switch(key)
  186. {
  187. case 'alpha':
  188. obj.style.opacity=oTarget[key]/100;
  189. obj.style.filter="alpha(opacity:"+oTarget[key]+")";
  190. break;
  191. case 'zIndex':
  192. obj.style.zIndex=oTarget[key];
  193. break;
  194. case 'width':
  195. case 'height':
  196. obj.getElementsByTagName('img')[0].style[key]=oTarget[key]+'px';
  197. break;
  198. default:
  199. obj.style[key]=oTarget[key]+'px';
  200. break;
  201. }
  202. }
  203. if(fnCallBackEnd)
  204. {
  205. fnCallBackEnd();
  206. }
  207. }
  208. else
  209. {
  210. for(key in oTarget)
  211. {
  212. obj[key]+=oSpeed[key];
  213. switch(key)
  214. {
  215. case 'alpha':
  216. obj.style.opacity=obj[key]/100;
  217. obj.style.filter="alpha(opacity:"+obj[key]+")";
  218. break;
  219. case 'zIndex':
  220. //obj.style.zIndex=obj[key];
  221. obj.style.zIndex=oTarget[key];
  222. break;
  223. case 'width':
  224. case 'height':
  225. obj.getElementsByTagName('img')[0].style[key]=obj[key]+'px';
  226. break;
  227. default:
  228. obj.style[key]=obj[key]+'px';
  229. break;
  230. }
  231. }
  232. }
  233. }

华为轮播图

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>华为全屏轮播图</title>
  6. <style>
  7. * {padding: 0; margin: 0;}
  8. li {list-style: none;}
  9. #div1 {min-width: 1000px; height: 296px; position: relative; overflow: hidden;}
  10. #div1 ul {position: absolute; left; 0}
  11. #div1 ul li {float: left;}
  12. #div1 ul li img {position: relative;}
  13. #btn {position: absolute; width: 100%; text-align: center; bottom: 0;}
  14. #btn a {cursor: pointer; display: inline-block; width: 11px; height: 11px; background: #666;}
  15. #btn a.active {background: white;}
  16. #btn a:hover {background: white;}
  17. /*min-width属性ie不支持,下面是一个hack*/
  18. *html .ie6_out {margin-left: 1000px; zoom: 1;}
  19. *html .ie6_in {position: relative; float: left; margin-left: -1000px;}
  20. </style>
  21. <script src="move.js"></script>
  22. <script>
  23. window.onload = function(){
  24. var oDiv = document.getElementById('div1');
  25. var oUl = oDiv.getElementsByTagName('ul')[0];
  26. var aLi = oUl.getElementsByTagName('li');
  27. var aImg = oUl.getElementsByTagName('img');
  28. var oBtn = document.getElementById('btn');
  29. var aA = oBtn.getElementsByTagName('a');
  30. var imgWidth = 1680;
  31. var iNow = 0;
  32. var iNow2 = 0;
  33. oUl.style.width = aImg.length * imgWidth + 'px';
  34. function toReSize(){
  35. var veiwWidth = document.documentElement.clientWidth;
  36. if(veiwWidth>1000){
  37. for(var i=0;i<aImg.length;i++){
  38. aImg[i].style.left = - (imgWidth - veiwWidth)/2 + 'px';
  39. }
  40. }
  41. }
  42. toReSize();
  43. window.onresize = function(){
  44. toReSize();
  45. };
  46. for(var i=0;i<aA.length;i++){
  47. aA[i].index = i;
  48. aA[i].onclick = function(){
  49. for(var i=0;i<aA.length;i++){
  50. aA[i].className = '';
  51. }
  52. this.className = 'active';
  53. startMove(oUl,{left : - this.index * imgWidth});
  54. };
  55. }
  56. //setInterval(toRun,3000);
  57. var timer = null;
  58. var bBtn = true;
  59. window.onblur=function(){
  60. if(bBtn){
  61. clearInterval(timer);
  62. bBtn = false;
  63. }
  64. };
  65. window.onfocus=function(){
  66. if(!bBtn){
  67. timer = setInterval(toRun,3000);
  68. bBtn = true;
  69. }
  70. };
  71. timer = setInterval(toRun,3000);
  72. function toRun(){
  73. if(iNow == aLi.length-1){
  74. aLi[0].style.position = 'relative';
  75. aLi[0].style.left = aLi.length * imgWidth + 'px';
  76. iNow = 0;
  77. }
  78. else{
  79. iNow++;
  80. }
  81. iNow2++;
  82. for(var i=0;i<aA.length;i++){
  83. aA[i].className = '';
  84. }
  85. aA[iNow].className = 'active';
  86. startMove(oUl,{left : - iNow2 * imgWidth},function(){
  87. if(iNow==0){
  88. aLi[0].style.position = 'static';
  89. oUl.style.left = 0;
  90. iNow2 = 0;
  91. }
  92. });
  93. }
  94. };
  95. </script>
  96. </head>
  97. <body>
  98. <!--[if lte IE 6]>
  99. <div class="ie6_out">
  100. <div class="ie6_in">
  101. <![endif]-->
  102. <div id="div1">
  103. <ul>
  104. <li><img src="01.jpg"></li>
  105. <li><img src="02.jpg"></li>
  106. <li><img src="03.jpg"></li>
  107. </ul>
  108. <div id="btn">
  109. <a href="javascript:;" class="active"></a>
  110. <a href="javascript:;"></a>
  111. <a href="javascript:;"></a>
  112. </div>
  113. </div>
  114. <!--[if lte IE 6]>
  115. </div>
  116. </div>
  117. <![endif]-->
  118. </body>
  119. </html>

苹果系统文件倒影

style.js文件

  1. function getBroswerType()
  2. {
  3. var Sys = {};
  4. var ua = navigator.userAgent.toLowerCase();
  5. var s;
  6. (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
  7. (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
  8. (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
  9. (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
  10. (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
  11. return Sys;
  12. }
  13. function getCss(obj, attr)
  14. {
  15. if(attr=="rotate")
  16. {
  17. return obj.rotate;
  18. }
  19. var i=parseFloat(obj.currentStyle?obj.currentStyle[attr]:document.defaultView.getComputedStyle(obj, false)[attr]);
  20. var val=i?i:0;
  21. if(attr=="opacity")
  22. {
  23. val*=100;
  24. }
  25. return val;
  26. }
  27. function setCss(obj,oAttr)
  28. {
  29. var sAttr="";
  30. var arr=["Webkit","Moz","O","ms",""];
  31. for(sAttr in oAttr)
  32. {
  33. if(sAttr.charAt(0)=="$")
  34. {
  35. for(var i=0;i<arr.length;i++)
  36. {
  37. obj.style[arr[i]+sAttr.substring(1)]=oAttr[sAttr];
  38. }
  39. }
  40. else if(sAttr=="rotate")
  41. {
  42. obj.rotate=oAttr[sAttr];
  43. var a=Math.cos(obj.rotate/180*Math.PI);
  44. var b=Math.sin(obj.rotate/180*Math.PI);
  45. var c=-Math.sin(obj.rotate/180*Math.PI);
  46. var d=Math.cos(obj.rotate/180*Math.PI);
  47. for(var i=0;i<arr.length;i++)
  48. {
  49. obj.style[arr[i]+"Transform"]="matrix("+a+","+b+","+c+","+d+","+0+","+0+")";
  50. }
  51. obj.style.filter="progid:DXImageTransform.Microsoft.Matrix( M11="+a+", M12="+c+", M21="+b+", M22="+d+",SizingMethod='auto expand')";
  52. }
  53. else
  54. {
  55. var value=oAttr[sAttr];
  56. switch(sAttr)
  57. {
  58. case 'width':
  59. case 'height':
  60. case 'paddingLeft':
  61. case 'paddingTop':
  62. case 'paddingRight':
  63. case 'paddingBottom':
  64. value=Math.max(value,0);
  65. case 'left':
  66. case 'top':
  67. case 'marginLeft':
  68. case 'marginTop':
  69. case 'marginRight':
  70. case 'marginBottom':
  71. obj.style[sAttr]=value+'px';
  72. break;
  73. case 'opacity':
  74. if(value<0)
  75. {
  76. value=0;
  77. }
  78. obj.style.filter="alpha(opacity:"+value+")";
  79. obj.style.opacity=value/100;
  80. break;
  81. default:
  82. obj.style[sAttr]=value;
  83. }
  84. }
  85. }
  86. }

html代码

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>仿苹果系统文件倒影展示效果-妙味课堂-www.miaov.com</title>
  6. <style>
  7. html{height:100%;background:#000;}
  8. body{margin:0;height:100%;overflow:hidden;}
  9. #wrap{ height:500px;width:1024px; position:absolute;left:50%;top:50%;margin:-250px 0 0 -512px;}
  10. #imgList{ position:absolute;}
  11. h1,p { text-align:center; color:#f1f1f1; word-spacing:15px; position:relative; top:10px; z-index:2; }
  12. h1 a,p a { color:#f1f1f1; text-decoration:none; }
  13. h1 a:hover,p a:hover { color:#fff; border-bottom:1px dotted #fff; }
  14. </style>
  15. <script src="js/style.js"></script>
  16. <script>
  17. window.onload=function()
  18. {
  19. var oBox=document.getElementById("wrap");
  20. var oList=document.getElementById("imgList");
  21. var aImg=oList.getElementsByTagName("img");
  22. var aDiv=[];
  23. var iImgWidth=300;
  24. var iInterval=100;
  25. var iStarWidth=1024;
  26. var iStarHeight=500;
  27. var iHeight=0;
  28. var iLeft=-20;
  29. var iZindex=0;
  30. var iStarNow=0;
  31. var iDeg=45;
  32. var iNow=0;
  33. var iGap=200;
  34. var sHtml="";
  35. var aSpan=[];
  36. setCss(oBox,{$Perspective:"800px"});
  37. for(var i=0; i<aImg.length;i++)
  38. {
  39. setCss(aImg[i],{width:iImgWidth});
  40. sHtml+="<div style='width:"+aImg[i].offsetWidth+"px;height:"
  41. +aImg[i].offsetHeight+"px;background:url("+aImg[i].src+") no-repeat; background-size:100% 100%;display:none; position:absolute;bottom:0;'><span style='width:"+aImg[i].offsetWidth+"px;height:"
  42. +aImg[i].offsetHeight+"px;background:-webkit-linear-gradient(top, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0.3)),url("+aImg[i].src+") no-repeat;background:-moz-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6)),url("+aImg[i].src+") no-repeat;background:-o-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6)),url("+aImg[i].src+") no-repeat;background:linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6)),url("+aImg[i].src+") no-repeat;background-size:100% 100%,100% 100%;position:absolute;'></span></div>";
  43. }
  44. oList.innerHTML="";
  45. oList.innerHTML=sHtml;
  46. aDiv=oList.getElementsByTagName("div");
  47. aSpan=oList.getElementsByTagName("span");
  48. for(i=0;i<aDiv.length;i++)
  49. {
  50. iLeft+=iInterval;
  51. if(i<Math.floor(aDiv.length/2))
  52. {
  53. iZindex=i;
  54. setCss(aDiv[i],{$Transform:"translateZ(-200px) rotateY("+iDeg+"deg)",left:iLeft,zIndex:iZindex,display:"block",$TransformStyle:"preserve-3d"});
  55. }
  56. else if(i>Math.floor(aDiv.length/2))
  57. {
  58. iZindex=aImg.length-i;
  59. setCss(aDiv[i],{$Transform:"translateZ(-200px) rotateY("+-iDeg+"deg)",left:iLeft,zIndex:iZindex,display:"block",$TransformStyle:"preserve-3d"});
  60. }
  61. else
  62. {
  63. iZindex=i;
  64. iLeft+=iGap;
  65. setCss(aDiv[i],{$Transform:"translateZ(200px)",left:iLeft,zIndex:iZindex,display:"block",$TransformStyle:"preserve-3d"});
  66. setCss(oList,{left:(oBox.offsetWidth/2-(iLeft+iImgWidth/2))});
  67. iStarNow=iNow=i;
  68. iLeft+=iGap;
  69. }
  70. setCss(aSpan[i],{$TransformOrigin:"bottom",$Transform:"rotateX(180deg)"})
  71. iHeight=Math.max(iHeight,aDiv[i].offsetHeight);
  72. aDiv[i].index=i;
  73. aDiv[i].onclick=function()
  74. {
  75. if(this.index==iNow)
  76. {
  77. return;
  78. }
  79. iLeft=(iStarNow-this.index)*iInterval;
  80. iNow=this.index;
  81. tab(aDiv,iNow,iLeft,iInterval,iGap);
  82. }
  83. }
  84. setCss(oList,{height:iHeight,top:oBox.offsetHeight/2-iHeight/2,$TransformStyle:"preserve-3d"});
  85. window.onresize=resize;
  86. function resize()
  87. {
  88. var iWidth=document.documentElement.clientWidth;
  89. var iHeight=document.documentElement.clientHeight;
  90. setCss(oBox,{$Transform:"scale("+Math.min(iWidth/iStarWidth,iHeight/iStarHeight)+")"});
  91. };
  92. resize();
  93. };
  94. function tab(aImg,iNow,iLeft,iInterval,iGap)
  95. {
  96. var iImgWidth=300;
  97. var iInterval=100;
  98. var iZindex=0;
  99. var iDeg=45;
  100. for(var i=0;i<aImg.length;i++)
  101. {
  102. setCss(aImg[i],{$Transition:"0.7s all ease"});
  103. iLeft+=iInterval;
  104. if(i<iNow)
  105. {
  106. iZindex=i;
  107. setCss(aImg[i],{$Transform:"translateZ(-200px) rotateY("+iDeg+"deg)",left:iLeft,zIndex:iZindex});
  108. }
  109. else if(i>iNow)
  110. {
  111. iZindex=aImg.length-i;
  112. setCss(aImg[i],{left:iLeft,$Transform:"translateZ(-200px) rotateY("+-iDeg+"deg)",zIndex:iZindex});
  113. }
  114. else
  115. {
  116. iZindex=i;
  117. iLeft+=iGap;
  118. setCss(aImg[i],{width:iImgWidth,$Transform:"translateZ(200px) rotateY(0deg)",left:iLeft,zIndex:iZindex});
  119. iLeft+=iGap;
  120. }
  121. }
  122. }
  123. </script>
  124. </head>
  125. <body>
  126. <h1><a href="http://www.miaov.com/">妙味课堂</a>——苹果系统文件倒影展示效果</h1>
  127. <p><a href="http://bbs.miaov.com/forum.php?mod=viewthread&tid=6277">>>源文件下载、交流讨论</a></p>
  128. <div id="wrap">
  129. <div id="imgList">
  130. <img src="img/1.jpg" alt=""/>
  131. <img src="img/2.jpg" alt=""/>
  132. <img src="img/3.jpg" alt=""/>
  133. <img src="img/4.jpg" alt=""/>
  134. <img src="img/5.jpg" alt=""/>
  135. <img src="img/6.jpg" alt=""/>
  136. <img src="img/7.jpg" alt=""/>
  137. <img src="img/8.jpg" alt=""/>
  138. <img src="img/9.jpg" alt=""/>
  139. <img src="img/10.jpg" alt=""/>
  140. <img src="img/11.jpg" alt=""/>
  141. <img src="img/1.jpg" alt=""/>
  142. <img src="img/2.jpg" alt=""/>
  143. <img src="img/3.jpg" alt=""/>
  144. <img src="img/4.jpg" alt=""/>
  145. <img src="img/5.jpg" alt=""/>
  146. <img src="img/6.jpg" alt=""/>
  147. <img src="img/7.jpg" alt=""/>
  148. <img src="img/8.jpg" alt=""/>
  149. <img src="img/9.jpg" alt=""/>
  150. <img src="img/10.jpg" alt=""/>
  151. <img src="img/11.jpg" alt=""/>
  152. </div>
  153. </div>
  154. </body>
  155. <script>
  156. if(getBroswerType().ie || getBroswerType().opera || parseFloat(getBroswerType().chrome)<12 || parseFloat(getBroswerType().firefox)<12 || parseFloat(getBroswerType().safari)<4)
  157. {
  158. toMiaoV();
  159. }
  160. function toMiaoV()
  161. {
  162. document.body.innerHTML="对不起,您的浏览器版本过低请升级,建议使用chrome 12.0(或firefox 12.0 、safari 4.0)以上浏览器浏览本效果";
  163. with(document.body.style)
  164. {
  165. textAlign="center";
  166. padding="0 100px"
  167. font="bold 50px/150px '微软雅黑'";
  168. color="#fff";
  169. }
  170. setTimeout(function()
  171. {
  172. window.location.href="http://www.miaov.com";
  173. },5000);
  174. }
  175. </script>
  176. </html>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注