Advertisement
fgoldwyn

header image fade in fade out

Feb 13th, 2012
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html14/loose.dtd">
  3.  
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html" charset="utf-8">
  7. <title>
  8. header fade in out
  9. </title>
  10. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=3.0.1">
  11. </script>
  12. <script type="text/javascript">
  13. //code by Jack Keller and found on www.icodesnippet.com
  14. $(document).ready(function($){
  15.  
  16. $(window).load(function() { //start after HTML, images have loaded
  17. var InfiniteRotator =
  18. {
  19. init: function()
  20. {
  21. //initial fade-in time (in milliseconds)
  22. var initialFadeIn = 1000;
  23.  
  24. //interval between items (in milliseconds)
  25. var itemInterval = 5000;
  26.  
  27. //cross-fade time (in milliseconds)
  28. var fadeTime = 2500;
  29.  
  30. //count number of items
  31. var numberOfItems = $('.rotating-item').length;
  32.  
  33. //set current item
  34. var currentItem = 0;
  35.  
  36. //show first item
  37. $('.rotating-item').eq(currentItem).fadeIn(initialFadeIn);
  38.  
  39. //loop through the items
  40. var infiniteLoop = setInterval(function(){
  41. $('.rotating-item').eq(currentItem).fadeOut(fadeTime);
  42. if(currentItem == numberOfItems -1){
  43. currentItem = 0;
  44. }else{
  45. currentItem++;
  46. }
  47. $('.rotating-item').eq(currentItem).fadeIn(fadeTime);
  48. }, itemInterval);
  49. }
  50. };
  51. InfiniteRotator.init();
  52. });
  53. });
  54. </script>
  55. <style type="text/css" media="all">
  56.  
  57. div#rotating-item-wrapper {
  58. position: relative;
  59. width: 1000px;
  60. height: 288px;
  61. }
  62.  
  63. img.rotating-item {
  64. display: none;
  65. position: absolute;
  66. top: 0;
  67. left: 0;
  68. }
  69. </style>
  70. </head>
  71. <body>
  72. <div id="rotating-item-wrapper">
  73. <img class="rotating-item" src="http://greenhillsoaps.com/wp-content/uploads/2012/01/cropped-iStock_000017900426Large.jpg" alt="#########"/>
  74. <img class="rotating-item" src="http://greenhillsoaps.com/wp-content/uploads/2012/01/cropped-iStock_000018253040Medium.jpg" alt="#########"/>
  75. <img class="rotating-item" src="http://greenhillsoaps.com/wp-content/uploads/2012/01/cropped-iStock_000005274216Medium.jpg" alt="#########"/>
  76. <img class="rotating-item" src="http://greenhillsoaps.com/wp-content/uploads/2012/01/cropped-iStock_000005576609Medium.jpg" alt="#########"/>
  77. <img class="rotating-item" src="http://greenhillsoaps.com/wp-content/uploads/2012/01/cropped-iStock_000004795672Medium.jpg" alt="#########"/>
  78. <img class="rotating-item" src="http://greenhillsoaps.com/wp-content/uploads/2012/01/cropped-iStock_000014561712Medium.jpg" alt="#########"/>
  79. </div>
  80. </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement