Advertisement
Guest User

Untitled

a guest
Nov 5th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. HTML
  2. <!doctype html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title>DYNAMIC</title>
  7. <link rel="stylesheet" type="text/stylesheet" href="style.css">
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  9. <script src="script.js"></script>
  10. </head>
  11. <body>
  12. <div class="nav_bar">
  13. <div class="nav_bar_sub">
  14. <div class="sub_wrap">
  15. <div class="menu_item nice_button"><p class="sub_text">NICE</p></div>
  16. <div class="menu_item anotherone_button"><p class="sub_text">Another One</p></div>
  17. </div>
  18. </div>
  19. <div class="nav_bar_animate"></div>
  20. </div>
  21. <div class="nice">
  22. <h1 align="center">DOGS</h1>
  23. <div class="parent_comment">
  24. <p class="comment_content">I love dogs</p>
  25. <div class="child_comment">
  26. <p class="comment_content">Me too!</p>
  27. <div class="child_comment">
  28. <P class="comment_content">I would like to agree</P>
  29. <div class="child_comment">
  30. <p class="comment_content">I would agree</p>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="child_comment">
  35. <p class="comment_content">but ofcourse</p>
  36. <div class="child_comment">
  37. <p class="comment_content">dogs are fine animals</p>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="parent_comment">
  42. <p class="comment_content">Dogs are a great aminal!</p>
  43. <div class="child_comment">
  44. <p class="comment_content">huzzah!</p>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="rem"></div>
  49. </body>
  50. </html>
  51. JavaScript
  52. $(document).ready(function(){
  53. 'use strict';
  54. var animated = $('.nav_bar_animate');
  55. var nav = $('.nav_bar');
  56. var nav_sub = $('.nav_bar_sub');
  57. var sub_wrap = $('.sub_wrap');
  58. var menu_item = $('.menu_item');
  59. var sub_text = $('.sub_text');
  60. var rem = $('.rem').width();
  61. var nice = $('.nice');
  62. var nice_button = $('.nice_button');
  63. var parent_comment = $('.parent_comment');
  64. var comment_template = '<div class="comment_end"><p class="comment_author comment_ending">NAME </p><p class="comment_reply comment_ending">reply</p></div>';
  65. nav_sub.width(nav.width()-rem*2);
  66. menu_item.each(function(){
  67. $(this).width($(this).find('.sub_text').width());
  68. //$(this).height($(this).find('.sub_text').height());
  69. });
  70. menu_item.hover(function(){
  71. $(this).css({'background-color': 'blue'});
  72. $(this).find(sub_text).css({'color': 'black'});
  73. });
  74. menu_item.mouseleave(function(){
  75. $(this).css({'background-color': 'black'});
  76. $(this).find(sub_text).css({'color': 'blue'});
  77. });
  78. animated.animate({width: '1rem', height: '1rem', 'bottom': '0px', 'left': '0px'}, 0);
  79. var animate_animated = function(){
  80. animated.animate({width: nav.width()+'px'}, 'slow').done(
  81. animated.animate({width: '1rem', 'left': nav.width()-animated.width()+'px'}, 'slow').done(
  82. animated.animate({height: nav.height()+'px'}, 'fast').done(
  83. animated.animate({height: '1rem', 'bottom': nav.height()-animated.height()+'px'}, 'fast').done(
  84. animated.animate({width: nav.width()+'px', 'left': '0px'}, 'slow').done(
  85. animated.animate({width: '1rem'}, 'slow').done(
  86. animated.animate({height: nav.height()+'px', 'bottom': '0px'}, 'fast').done(
  87. animated.animate({height: '1rem'}, 'fast').done(
  88. animate_animated()
  89. ))))))));
  90. };
  91. parent_comment.each(function(){
  92. var child = $(this).find('.child_comment');
  93. child.each(function(){
  94. $(this).css({'left': rem});
  95. var content = $(this).find('.comment_content').first();
  96. if(!content.next().hasClass('comment_end')){
  97. content.append(comment_template.replace("NAME", 'anon '));
  98. }
  99. });
  100. });
  101. animate_animated();
  102. });
  103. CSS
  104. @charset "utf-8";
  105. body{
  106. background-color: black;
  107. }.nav_bar{
  108. position: relative;
  109. background-color: black;
  110. width: auto;
  111. height: 6rem;
  112. }.nav_bar_animate{
  113. position: absolute;
  114. background-color: blue;
  115. width: auto;
  116. height: 6rem;
  117. }.nav_bar_sub{
  118. position: absolute;
  119. height: 4rem;
  120. width: 6rem;
  121. top: 1rem;
  122. left: 1rem;
  123. background-color: black;
  124. display: table;
  125. margin-left: 1rem;
  126. }.rem{
  127. position: fixed;
  128. visibility: hidden;
  129. height: 1rem;
  130. width: 1rem;
  131. }.sub_wrap{
  132. display: table-cell;
  133. vertical-align: middle;
  134. }.menu_item{
  135. background-color: black;
  136. width: auto;
  137. height: 1rem;
  138. padding: .5rem;
  139. display: inline-block;
  140. align-content: center;
  141. }.menu_item > p{
  142.  
  143. }.sub_text{
  144. display: table-cell;
  145. color: blue;
  146. vertical-align: middle;
  147. }.nice{
  148. background-color: blue;
  149. margin-top: 1rem;
  150. width: auto;
  151.  
  152. }.parent_comment{
  153. position: relative;
  154. left: 0rem;
  155. }.child_comment{
  156. position: relative;
  157. border-left: .1rem solid black;
  158. padding-left: .2rem;
  159. }.comment_end{
  160. border-top: .1rem solid black;
  161. display: table-cell;
  162. height: 1rem;
  163. }.comment_ending{
  164. display: inline-block;
  165. padding: none;
  166. margin: none;
  167. padding-right: .5rem;
  168. padding-left: .5rem;
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement