Advertisement
Guest User

Untitled

a guest
Mar 6th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Свайп меню</title>
  5. <meta charset="utf-8">
  6. <meta content="Официальный сайт кафедры И4 БГТУ &laquo;Военмех&raquo;" name="description">
  7. <meta content="И4, Кафедра, БГТУ, Военмех, официальный сайт" name="keywords">
  8. <link rel="stylesheet" href="SwipeMenu.css">
  9. <script src="http://yandex.st/jquery/2.1.0/jquery.js"></script>
  10. <script src="jquery-2.1.0.js"></script>
  11. <script src="swipemenu.js"></script>
  12.  
  13. </head>
  14. <body>
  15. <script src="http://yandex.st/jquery/2.1.0/jquery.js"></script>
  16. <script src="jquery-2.1.0.js"></script>
  17. <script src="swipemenu.js"></script>
  18. <div id="container">
  19. <div id="inner">
  20. <div id="home">
  21. <button id="sorokin">Сорокин</button><br><br>
  22. <button id="ivanov">Иванов</button><br><br>
  23. <button id="petrov">Петров</button>
  24. </div>
  25. <div class="member-home" data-href="sorokin">
  26. <button>Назад</button>
  27. <br>Фото Сорокина
  28. </div>
  29. <div class="member-home" data-href="ivanov" style="background: pink;">
  30. <button>Назад</button>
  31. <br>Фото Иванова
  32. </div>
  33. <div class="member-home" data-href="petrov" style="background: yellow;">
  34. <button>Назад</button>
  35. <br>Фото Петрова
  36. </div>
  37. </div>
  38. </div>
  39.  
  40. </body>
  41.  
  42. </html>
  43.  
  44.  
  45.  
  46.  
  47.  
  48. #container {
  49. position:relative;
  50. border: 1px solid black;
  51. width:400px;
  52. height:600px;
  53. overflow:hidden
  54. }
  55. #inner {
  56. position: relative;
  57. width: 800px;
  58. }
  59. #home {
  60. position:absolute;
  61. width: 400px;
  62. height: 600px;
  63. background-color: red;
  64. }
  65.  
  66. .member-home {
  67. position:absolute;
  68. left:400px;
  69. width: 400px;
  70. height: 600px;
  71. background-color: green;
  72. z-index: 1;
  73. }
  74.  
  75.  
  76.  
  77.  
  78.  
  79. function toggleDivs(e) {
  80. var $inner = $("#inner");
  81.  
  82. var target = $(e.currentTarget).attr('id')
  83.  
  84.  
  85.  
  86. // See which divs> should be animated in/out.
  87. if ($inner.position().left == 0) {
  88. $('[data-href='+ target +']').css('z-index', 2)
  89. $inner.animate({
  90. left: "-400px"
  91. });
  92.  
  93. }
  94. else {
  95.  
  96. $inner.animate({
  97. left: "0px"
  98. }, function() {
  99. $('.member-home').css('z-index', 1)
  100. });
  101. }
  102. }
  103.  
  104. $("button").on("click", function(e) {
  105. toggleDivs(e);
  106. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement