gpt4 book ai didi

javascript - Accordion 子菜单不会向下滑动

转载 作者:行者123 更新时间:2023-11-28 03:24:14 24 4
gpt4 key购买 nike

使 Accordion 菜单失去了向下/向上滑动功能我做错了什么?有人可以检查这段代码吗

查询

$(document).ready(function() {
$('.nav-pills ul li').on('click touchstart', function(e) {
e.preventDefault();

var checkElement = $(this).next();

$('.nav-pills li').removeClass('open');
$(this).closest('li').addClass('open');

if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
$(this).closest('li').removeClass('open');
checkElement.slideUp(300);
}
if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
$('nav-pills ul ul:visible').slideUp(300);
checkElement.slideDown(300);
}
if($(this).closest('li').find('ul').children().length == 0){
return true;
}
else {
return false;
}
});
});

HTML

<div class="nav-container">
<div class="nav nav-pills nav-stacked">
<ul class="nav nav-pills nav-stacked">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Is Landscape Architecture Right For Me?</a>
<ul class="dropdown-menu">
<li><a href="http://www.asla.org/design/index.html" target="_blank">What Is Landscape Architecture?</a></li>
<li><a href="http://www.youtube.com/watch?v=zbx3FDDNeQM" target="_blank">I Want to Be a Landscape Architect (Video)</a>
<li><a href="http://www.asla.org/ContentDetail.aspx?id=12206&PageTitle=Education&RMenuId=54">What Skills Do I Need?</a></li>
<li><a href="http://www.bls.gov/ooh/architecture-and-engineering/landscape-architects.htm" target="_blank">Future Career Prospects (U.S. Labor Department)</a></li>
</ul>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">What Does A Landscape Architects Do?</a>
<ul class="dropdown-menu">
<li><a href="http://www.asla.org/ContentDetail.aspx?id=22922">Interviews with Leading Landscape Architects</a></li>
<li><a href="http://www.asla.org/2013awards/index.html">ASLA Professional Awards</a></li>
<li><a href="http://www.asla.org/2013studentawards/index.html">ASLA Student Awards</a></li>
<li><a href="http://astore.amazon.com/a04806-20/detail/0470338458/190-5667858-4355216" target="_blank">Buy the Book:&nbsp;<em>Becoming A Landscape Architect</em></a></li>
</ul>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Why Is Their Work So Important?</a>
<ul class="dropdown-menu">
<li><a href="http://www.asla.org/sustainablelandscapes/index.html">Designing Our Future: Sustainable Landscapes</a></li>
<li><a href="http://www.asla.org/sustainablelandscapes/videos.html">ASLA Animations</a></li>
</ul>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Where Can I Study?</a>
<ul class="dropdown-menu">
<li><a href="http://www.asla.org/schools.aspx">Picking A School</a></li>
<li><a href="http://store.di.net/collections/reports" target="_blank">DesignIntelligence Rankings (2013)</a></li>
</ul>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">How Do I Learn More?</a>
<ul class="dropdown-menu">
<li><a href="http://www.asla.org/uploadedFiles/CMS/Education/Career_Discovery/2013%20ASLA%20Graduating%20Students%20Report%200%202.pdf" target="_blank">Graduating Student Surveys</a></li>
<li><a href="http://www.acementor.org/" target="_blank">ACE Mentor Program</a></li>
<li><a href="http://www.asla.org/studentchapters.aspx">Find An ASLA Student Chapter</a></li>
<li><a href="http://www.asla.org/software.aspx">Learn New Software Programs</a></li>
<li><a href="http://www.nps.gov/ncrc/programs/rtca/whatwedo/projects_by_state.html" target="_blank">Local Parks / Conservation Programs</a></li>
</ul>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Personal Stories</a>
<ul class="dropdown-menu">
<li><a href="#">The Path</a></li>
<li><a href="#">Obstacles</a></li>
<li><a href="#">Aids</a></li>
</ul>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">About Columbus Circle</a>
<ul class="dropdown-menu">
<li><a href="http://asla.org/awards/2006/06winners/238.html">Learn More About Columbus Circle</a></li>
<li><a href="img/0173ColCir_062_c_before.jpg">Before Photo</a></li>
</ul>
</ul>
</div>
</div>
</div>

CSS

.nav-pills > li > a {
border-radius: 0px;
line-height: 1.5;
}

.nav-container {
max-width: 26%;
width: 280px;
top: 90px;
left: 45px;
padding: 0;
background-color: #000000;
position: fixed;
z-index: 3;
cursor: pointer;
}

.nav .open>a,
.nav .open>a:hover,
.nav .open>a:focus {
background-color: #f26527;
color: #ffffff;
}

.dropdown > a {
color: #ffffff;
}

.dropdown-menu {
border-radius: 0px;
padding: 0px;
position: relative;
width: 345px;
z-index: 4;
}

.dropdown-menu > li > a {
line-height: 1.3;
}

.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
color: #ffffff;
background-color: #f26527;
}

.dropdown-menu li {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica", "Ariel", "sans- serif";
font-weight: 300;
background: #ffffff;
line-height: 1.5;
}

菜单像 Accordion 一样工作,但再次失去了滑动功能,它只是落下

谢谢

最佳答案

我也遇到过这种情况,如果您在这里尝试了所有可能的解决方案,答案是列表不能动画化,如果您正在尝试动画化列表。最好的方法是将列表包装在一个 div 中。

关于javascript - Accordion 子菜单不会向下滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22258863/

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