gpt4 book ai didi

javascript - Bootstrap v4.3 Navbar 没有正确动画折叠的非导航栏元素的显示过渡

转载 作者:太空宇宙 更新时间:2023-11-04 00:48:17 25 4
gpt4 key购买 nike

我创建了一个经过修改的药丸菜单系统,该系统在小屏幕和移动设备上显示折叠结构。我遇到的问题是,当按下“菜单”按钮时,如果它们是导航栏的一部分,我希望药丸元素不会显示过渡效果,而是需要大约半秒的时间才能出现,这是不理想。我假设过渡以相对于导航栏的方式工作,因此需要稍微改变方法以显示手动隐藏元素,就像我在下面的示例中那样:

.xs-collapse {
display: none;

}

body {
background-color: aqua;
}



@media (min-width: 992px) {
.xs-toggle {
display: none;
visibility: hidden;
}
.xs-collapse {
display: block;

}
}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<title>Hello, wasasorld!</title>
</head>
<body>

<div class="container">
<!-- Container start -->
<div class="row">

<!-- row start -->
<div class="col-lg-4">

<nav class="navbar navbar-expand-lg navbar-light bg-light xs-toggle">
<a class="navbar-brand" href="#">
<img src="./images/logo.svg" height="40" class="d-inline-block align-top" alt="">

</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#v-pills-tab" aria-controls="v-pills-tab" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>


<ul class="nav flex-column nav-pills xs-collapse collapse" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<li><a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a></li>
<li><a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a></li>
<li><a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a></li>
<li><a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a></li>
</ul>
</div>

<div class="col-lg-8">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">...</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
</div>
</div>




<!-- row end -->
</div>



<!-- Container end -->
</div>


<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<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>

</body>
</html>

如您所见,菜单项无法正常工作,我们将不胜感激解决此问题的任何帮助。

非常感谢:)

最佳答案

我只贴出了相关的代码给你。这将为您指明正确的方向。

<nav class="navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<div class="collapse" id="navbarToggleExternalContent">
<div class="bg-dark p-4">
<h4 class="text-white">Collapsed content</h4>
<span class="text-muted">Toggleable via the navbar brand.</span>
</div>
<ul class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<li><a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a></li>
<li><a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a></li>
<li><a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a></li>
<li><a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a></li>
</ul>
</div>

here is fiddle:

关于javascript - Bootstrap v4.3 Navbar 没有正确动画折叠的非导航栏元素的显示过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56584300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com