gpt4 book ai didi

jquery 向下滑动功能无法在导航栏中实现

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

我正在尝试创建一个导航栏。将鼠标悬停在其上时,下拉菜单应向下滑动。但就我而言,这没有发生。我首先尝试使用 css,但它没有用,然后我再次开始使用 jquery。它不会向下滑动,也没有任何反应。有人可以指导我吗?这将提供巨大的帮助。

$(document).ready(function () {

$(".nav-item").hover('hover', function () {
var delayTime = 550;
var $dropdown = $(this).next(".dropdrown");
if($dropdown.is(':visible')){
$dropdown.delay(delayTime).slideDown("slow");
} else {
$dropup.delay(delayTime).slideUp("slow");
}
$(".dropdown").hide();
});



});
nav ul li a{
line-height:59px;
-webkit-transition: background-color 1s;
-moz-transition: background-color 1s;
-o-transition: background-color 1s;
transition: background-color 1s;
}

nav .navbar-nav .nav-item .nav-link:hover, .dropdown:hover .dropbtn{
background-color: #f1c575;
}

nav .navbar-nav .nav-item .nav-link {
position: relative;
}

nav .navbar-nav .nav-item .nav-link:hover:after {
content: "";
display: block;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #7B8B93;
position: absolute;
left: 35%;
bottom: 0px;
}

/* Nav Menu Starts */

.dropdown-content {
display: none;
position: absolute;
background-color: #7b8b93;
width: 100%;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
-webkit-transition: height 2s; /* For Safari 3.1 to 6.0 */
transition: height 2s;
}

nav ul li .dropdown:hover .dropdown-content {
display: block;
height: 300px;
}

.dropdown{
position: initial;
}


.nav-link:hover + .dropdown .dropdown-content{
display: block;
}

/* Nav Menu Ends*/
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">LoGo</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="navbar-nav ml-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="#">Capabilities</a>
<div class="dropdown">
<div class="dropdown-content">
<div class="row">
<div class="col-lg-4">
<h3 class="ml-3">Products</h3>
<p class="ml-3"><a class="commerce" href="#">Dr.Commerce</a></p>
</div>
<div class="col-lg-8 services">
<h3>Capabilities</h3>
<ul class="list-inline">
<li class="list-inline-item">
<img src="./images/twitter-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>

</ul>
</div>
</div>
</div>
</div>
</li>
</ul>
</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="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>

最佳答案

使用 $(".nav-item").hover( function () {

$(".nav-item").on('hover', function () {hover 期望第一个参数是一个回调。

关于jquery 向下滑动功能无法在导航栏中实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54171153/

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