Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
237 views
in Technique[技术] by (71.8m points)

css - How to make bubble navbar animation in bootstrap?

I will leave the animation I want to do. Due to Bootstrap's default features, I cannot do what I have to do. Since I am not very good at JavaScript, I could not do the necessary interventions. Isn't there a way to disable some default features of Bootstrap? or a convenience for animations. How can I get these and similar animations in Bootstrap without difficulty? Also, circle doesn't appear above the navbar. The z-index settings I made didn't work.

Animation: https://codepen.io/BerkayAkgurgen/pen/gOwdgeB

const hamburger = document.querySelector('.navbar-toggler');
const navLinks = document.querySelector('.menu');
const links = document.querySelectorAll('.menu li');

hamburger.addEventListener('click', () => {
    navLinks.classList.toggle("open");
    links.forEach(link => {
        link.classList.toggle('fade');
    });
});
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

@media screen and (max-width:900px) {

    .collapsing {
        transition: all 1s ease-out;
    }

   .collapse.show{
         background:red;
        height: 100vh;
        width: 100%;
        flex-direction: column;
        clip-path: circle(1000px at 90% -15%);
        -webkit-clip-path: circle(1000px at 90% -15%);
        z-index: 999;
   }

    .navbar{
        margin: 0;
        padding: 0;
        z-index: 6;
    }

    .navbar-collapse {
        background:red;
        height: 100vh;
        width: 100%;
        flex-direction: column;
        clip-path: circle(900px at 90% -15%);
        -webkit-clip-path: circle(1000px at 90% -15%);
        transition: all 1s ease-out;
        z-index: 2000;
        z-index: 998;
    }

    .navbar-toggler.open {
        clip-path: circle(1000px at 90% 10%);
        -webkit-clip-path: circle(1000px at 90% -10%);
      }

      .navbar-collapse li {
        transition: all 0.5s ease 0.8s;
      }

      li.fade {
        opacity: 1;
      }
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
    integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
  <link rel="stylesheet" href="berkay.css">
  <title>Todo List</title>
</head>

<body>
  <nav class="topbar2 navbar navbar-expand-lg navbar-light bg-light" style="z-index: 2;">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
  
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class=" menu navbar-nav mr-auto">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Dropdown
          </a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdown">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Something else here</a>
          </div>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
        </li>
      </ul>
      <form class="form-inline my-2 my-lg-0">
        <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
      </form>
    </div>
  </nav>
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
    integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous">
  </script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
    integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous">
  </script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
    integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous">
  </script>
  <!-- <script src="berkay.js"></script> -->
</body>

</html>
question from:https://stackoverflow.com/questions/65660316/how-to-make-bubble-navbar-animation-in-bootstrap

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...