Wacky_rubia

галерея

Nov 15th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.63 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Fotogallery</title>
  6. <style>
  7. .big_picture {
  8. z-index: 3,
  9. position : absolute,
  10. left : 400px,
  11. top : 100px
  12. }
  13. h1 {
  14. text-align: center;
  15. }
  16. div #largeImg {
  17. display: block;
  18. width: 550px;
  19. margin: auto;
  20. }
  21. .thumbs {
  22. background-color: green;
  23. position: absolute;
  24. top: 480px;
  25. height: 150px;
  26. width: 99%;
  27. }
  28. .mini {
  29. height: 100px;
  30. width: 100px;
  31. position: relative;
  32. top: 25px;
  33. }
  34. #img1 {
  35. left: 50px;
  36. }
  37. #img2 {
  38. left: 150px;
  39. }
  40. #img3 {
  41. left: 250px;
  42. }
  43. #img4 {
  44. left: 350px;
  45. }
  46. #img5 {
  47. left: 450px;
  48. }
  49. #img6 {
  50. left: 550px;
  51. }
  52. /*.but {
  53. height: 50;
  54. width: 50;
  55. position: relative;
  56. top: 30%;
  57. }*/
  58. #right_button {
  59. position: relative;
  60. top: 50px;
  61. float: right;
  62. }
  63. .but {
  64. z-index: 4;
  65. }
  66. </style>
  67.  
  68. </head>
  69. <body>
  70. <h1>Галерея <span>Image 1</span></h1>
  71. <div><img id="largeImg" src="img1-lg.jpg" alt="Large image"/></div>
  72. <p class="thumbs">
  73. <a id='left_button' class='but'><img src="left.png" /></a>
  74. <a href="img1-lg.jpg" title="Image 1" id='img1' class='mini'><img src="img1-thumb.jpg" /></a>
  75. <a href="img2-lg.jpg" title="Image 2" id='img2' class='mini'><img src="img2-thumb.jpg" /></a>
  76. <a href="img3-lg.jpg" title="Image 3" id='img3' class='mini'><img src="img3-thumb.jpg" /></a>
  77. <a href="img1-lg.jpg" title="Image 1" id='img4' class='mini'><img src="img1-thumb.jpg" /></a>
  78. <a href="img2-lg.jpg" title="Image 2" id='img5' class='mini'><img src="img2-thumb.jpg" /></a>
  79. <a href="img3-lg.jpg" title="Image 3" id='img6' class='mini'><img src="img3-thumb.jpg" /></a>
  80. <a id='right_button' class='but'><img src="right.png" /></a>
  81. </p>
  82. </body>
  83. </html>
  84. <script src="j.js"></script>
  85. <script>
  86. $("a img").click(function() {
  87. $("#largeImg").attr("src", $(this).parents("a").attr("href"));
  88. $("h1 span").html($(this).parents("a").attr("title"));
  89. return false;
  90. });
  91. </script>
  92.  
  93. <script>
  94. click_cont = 0
  95. $('#largeImg').click(function() {
  96. click_cont += 1;
  97. if (click_cont < 2)
  98. {
  99. var docHeight = $(document).height();
  100. $("<div id='overlay'></div>")
  101. .appendTo("body")
  102. .height(docHeight)
  103. .css({
  104. 'opacity': 0.7,
  105. 'position': 'absolute',
  106. 'top': 0,
  107. 'left': 0,
  108. 'background-color': 'black',
  109. 'width': '100%',
  110. 'z-index': 1
  111. });
  112.  
  113. $("<button id='b'>закрыть</button>")
  114. .appendTo("body")
  115. .height(docHeight)
  116. .css({
  117. 'position': 'absolute',
  118. 'top': 0,
  119. 'left': '1000px',
  120. 'width': '100px',
  121. 'height': '20px',
  122. 'z-index': 2
  123. });
  124.  
  125. $('#largeImg').css({
  126. 'z-index': 3,
  127. 'position' : 'absolute',
  128. 'left' : '400px',
  129. 'top' : '100px'
  130. });
  131.  
  132.  
  133. $("#b").click(function() {
  134. $("#overlay").remove();
  135. $(this).remove();
  136. $('#largeImg').css({
  137. 'position': 'static'
  138. })
  139. click_cont = 0;
  140. })
  141. }
  142. });
  143.  
  144. var img_sourses = [ ["img1-lg.jpg", "Image 1", "img1-thumb.jpg"],
  145. ["img2-lg.jpg", "Image 2", "img2-thumb.jpg"],
  146. ["img3-lg.jpg", "Image 3", "img3-thumb.jpg"],
  147. ["img1-lg.jpg", "Image 1", "img1-thumb.jpg"],
  148. ["img2-lg.jpg", "Image 2", "img2-thumb.jpg"],
  149. ["img3-lg.jpg", "Image 3", "img3-thumb.jpg"],
  150. ["img1-lg.jpg", "Image 1", "img1-thumb.jpg"]];
  151. var cur_first = 0;
  152.  
  153. $('#right_button').click(function() {
  154. alert("fesdkjferjdhrjg");
  155. cur_first = (cur_first + 6 - 1) % 6;
  156. for (var i = 0; i < 6; i++)
  157. {
  158. var str = '#img' + (i + 1).toString();
  159. var idx = (cur_first + i) % 6;
  160. var line = img_sourses[idx];
  161. $(str).attr('href', line[0]);
  162. $(str).attr('title', line[1]);
  163. $(str).attr('src', line[2]);
  164. }
  165. });
  166. $('#left_button').click(function() {
  167. cur_first = (cur_first + 1) % 6;
  168. for (var i = 0; i < 6; i++)
  169. {
  170. var str = '#img' + (i + 1).toString();
  171. var idx = (cur_first + i) % 6;
  172. var line = img_sourses[idx];
  173. $(str).attr('href', line[0]);
  174. $(str).attr('title', line[1]);
  175. $(str).attr('src', line[2]);
  176. }
  177. });
  178.  
  179.  
  180. </script>
Advertisement
Add Comment
Please, Sign In to add comment