Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTML
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>DYNAMIC</title>
- <link rel="stylesheet" type="text/stylesheet" href="style.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <script src="script.js"></script>
- </head>
- <body>
- <div class="nav_bar">
- <div class="nav_bar_sub">
- <div class="sub_wrap">
- <div class="menu_item nice_button"><p class="sub_text">NICE</p></div>
- <div class="menu_item anotherone_button"><p class="sub_text">Another One</p></div>
- </div>
- </div>
- <div class="nav_bar_animate"></div>
- </div>
- <div class="nice">
- <h1 align="center">DOGS</h1>
- <div class="parent_comment">
- <p class="comment_content">I love dogs</p>
- <div class="child_comment">
- <p class="comment_content">Me too!</p>
- <div class="child_comment">
- <P class="comment_content">I would like to agree</P>
- <div class="child_comment">
- <p class="comment_content">I would agree</p>
- </div>
- </div>
- </div>
- <div class="child_comment">
- <p class="comment_content">but ofcourse</p>
- <div class="child_comment">
- <p class="comment_content">dogs are fine animals</p>
- </div>
- </div>
- </div>
- <div class="parent_comment">
- <p class="comment_content">Dogs are a great aminal!</p>
- <div class="child_comment">
- <p class="comment_content">huzzah!</p>
- </div>
- </div>
- </div>
- <div class="rem"></div>
- </body>
- </html>
- JavaScript
- $(document).ready(function(){
- 'use strict';
- var animated = $('.nav_bar_animate');
- var nav = $('.nav_bar');
- var nav_sub = $('.nav_bar_sub');
- var sub_wrap = $('.sub_wrap');
- var menu_item = $('.menu_item');
- var sub_text = $('.sub_text');
- var rem = $('.rem').width();
- var nice = $('.nice');
- var nice_button = $('.nice_button');
- var parent_comment = $('.parent_comment');
- var comment_template = '<div class="comment_end"><p class="comment_author comment_ending">NAME </p><p class="comment_reply comment_ending">reply</p></div>';
- nav_sub.width(nav.width()-rem*2);
- menu_item.each(function(){
- $(this).width($(this).find('.sub_text').width());
- //$(this).height($(this).find('.sub_text').height());
- });
- menu_item.hover(function(){
- $(this).css({'background-color': 'blue'});
- $(this).find(sub_text).css({'color': 'black'});
- });
- menu_item.mouseleave(function(){
- $(this).css({'background-color': 'black'});
- $(this).find(sub_text).css({'color': 'blue'});
- });
- animated.animate({width: '1rem', height: '1rem', 'bottom': '0px', 'left': '0px'}, 0);
- var animate_animated = function(){
- animated.animate({width: nav.width()+'px'}, 'slow').done(
- animated.animate({width: '1rem', 'left': nav.width()-animated.width()+'px'}, 'slow').done(
- animated.animate({height: nav.height()+'px'}, 'fast').done(
- animated.animate({height: '1rem', 'bottom': nav.height()-animated.height()+'px'}, 'fast').done(
- animated.animate({width: nav.width()+'px', 'left': '0px'}, 'slow').done(
- animated.animate({width: '1rem'}, 'slow').done(
- animated.animate({height: nav.height()+'px', 'bottom': '0px'}, 'fast').done(
- animated.animate({height: '1rem'}, 'fast').done(
- animate_animated()
- ))))))));
- };
- parent_comment.each(function(){
- var child = $(this).find('.child_comment');
- child.each(function(){
- $(this).css({'left': rem});
- var content = $(this).find('.comment_content').first();
- if(!content.next().hasClass('comment_end')){
- content.append(comment_template.replace("NAME", 'anon '));
- }
- });
- });
- animate_animated();
- });
- CSS
- @charset "utf-8";
- body{
- background-color: black;
- }.nav_bar{
- position: relative;
- background-color: black;
- width: auto;
- height: 6rem;
- }.nav_bar_animate{
- position: absolute;
- background-color: blue;
- width: auto;
- height: 6rem;
- }.nav_bar_sub{
- position: absolute;
- height: 4rem;
- width: 6rem;
- top: 1rem;
- left: 1rem;
- background-color: black;
- display: table;
- margin-left: 1rem;
- }.rem{
- position: fixed;
- visibility: hidden;
- height: 1rem;
- width: 1rem;
- }.sub_wrap{
- display: table-cell;
- vertical-align: middle;
- }.menu_item{
- background-color: black;
- width: auto;
- height: 1rem;
- padding: .5rem;
- display: inline-block;
- align-content: center;
- }.menu_item > p{
- }.sub_text{
- display: table-cell;
- color: blue;
- vertical-align: middle;
- }.nice{
- background-color: blue;
- margin-top: 1rem;
- width: auto;
- }.parent_comment{
- position: relative;
- left: 0rem;
- }.child_comment{
- position: relative;
- border-left: .1rem solid black;
- padding-left: .2rem;
- }.comment_end{
- border-top: .1rem solid black;
- display: table-cell;
- height: 1rem;
- }.comment_ending{
- display: inline-block;
- padding: none;
- margin: none;
- padding-right: .5rem;
- padding-left: .5rem;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement