- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如果问题令人困惑,我深表歉意,我不太确定如何措辞。
基本上,我有一个 jquery 代码,它的作用是在嵌套在 li
中的 div
中显示内容。当我单击标题时,内容会下降,它会在视觉上将下一个标题向下推,但如果您单击已显示内容的任意位置,它不会向上滑动,而是会显示下一个内容。
Test Page <~~ 在此测试页面中,您可以看到示例,只需单击带有 + 的标题即可,直到您想要关闭它为止。
我不确定是什么导致了这个问题。
编辑 我注意到“+”号出现在“创建您自己的筹款页面”部分的图片正上方”,这是折叠时下一个标题出现的位置, 但加号在绝对范围内,所以它也应该向下移动,不是吗?
HTML:
<ul id="toggle-view">
<li>
<h6>Choose a fundraising idea</h6>
<span>+</span>
<div class="panel">
<p>here are countless ways to contribute! Shave your head, run a marathon, or give up your birthday - the choice is yours! We've listed some of our most popular fundraising ideas but feel free to run with your own idea by choosing the 'Other' stream.</p>
<br>
<img src="../images/content/pagebuilder/ChooseAStream_screenshot.png" alt="Choose a Stream screenshot" width="100%"/>
</div>
</li>
<li>
<h6>Create your own fundraising page</h6>
<span>+</span>
<div class="panel">
<p>Click on 'Register' to set up a fundraising page. You can set one up on your own or create a page where friends or colleagues can join you. Let us know what kind of fundraiser you're holding and we'll provide you with all the tools to help you succeed.</p>
<br>
<img src="../images/content/pagebuilder/PersonalPage_screenshot.png" align="left" alt="Personal page screenshot" width="100%"/>
</div>
</li>
<li>
<h6>Access your Participant Centre</h6>
<span>+</span>
<div class="panel">
<p>As a Canadian Cancer Society cancer fighter, you have access to an online Participant Centre where you’ll find customizable, interactive tools to get people excited about sharing in your fundraising success!</p>
<img src="../images/content/pagebuilder/ParticipantCentre_screenshot.png" align="left" alt="Participant Centre screenshot" width="100%"/>
</div>
</li>
</ul>
CSS:
/*Drop Down Content*/
#toggle-view {
list-style:none;
font-family:arial;
font-size:11px;
margin:0;
padding:0;
width: 50%;
}
#toggle-view li {
margin:10px;
border-bottom:1px solid #ccc;
position:relative;
cursor:pointer;
}
#toggle-view h6 {
margin:0;
font-size:14px;
}
#toggle-view span {
position:absolute;
right:5px; top:0;
color:#3498db;
font-size:13px;
}
#toggle-view .panel {
margin:5px 0;
display:none;
}
jQuery:
$(document).ready(function () {
$('#toggle-view li').click(function () {
var text = $(this).children('div.panel');
if (text.is(':hidden')) {
text.slideDown('200');
$(this).children('span').html('-');
} else {
text.slideUp('200');
$(this).children('span').html('+');
}
});
});
有什么建议吗?感谢您的宝贵时间!
最佳答案
问题是您的 li
内部有一个 float 图像,但图像后没有 float 清除机制。反过来,li
的计算高度不包括图像的高度,因此 +
符号显示在图像上方,根据CSS。
另外由于同样的问题,图片在下一个li
的空间,导致它注册了下一个内容的点击事件,而不是当前内容的事件。为了解决这个问题,向您的 CSS 添加一个简单的 clearfix 规则
#toggle-view li::after {
content: "";
display: block;
height: 0;
visibility: hidden;
clear: both;
}
这将在您的切换 View ul
中的每个 li
内容之后创建一个假想 block ,它将清除 li< 中的所有 float 元素
关于jquery - 使用jquery `<li><span>`时如何下推 `.slidedown()`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36849438/
A 使用 jquery 设计了一个两级菜单。当我将鼠标悬停在顶部菜单链接时,submenu 类名的 DIV 会向下滑动。当我将鼠标悬停在该 div 内时,会出现一个链接,类名为 subsubmenu
我正在为 Android 手机构建 PhoneGap 应用程序。我使用这样的机制让用户将数据提交到 Web 服务: $('#backdrop').slideDown('fast',function()
我有一个 div#items,如果单击它,则 div#choices slipDown()。如果再次单击,则 div#choices 应该 slipUp();我如何测试选择是否已经下降或上升?我知道我
我是 jquery 新手,我正在尝试在下拉菜单上使用 .slidedown 函数。我希望菜单在单击时打开,并在再次单击选项或菜单时关闭。然而,当按原样单击菜单时,它只是弹开和关闭,而不是保持打开状态。
如何在 css 设置为 display:none 的页面加载时使用 jquery 向下滑动 div?我看到了很多解决方案,但如果 css 设置为 display:none,则没有一个可以滑动 div。
为什么slideDown()第一次不起作用? $('#lnkInfo').click(function (e) { e.preventDefault(); $(this).blur()
我遇到了同样的问题,尽管我找不到解决方案,但我在网上读到了相关内容。 简单地说,当在我的 DIV 元素上使用 SlideDown() 方法时,我得到了丑陋的回弹效果,其中 jQuery 将 DIV 大
我在我的这个网站上使用 JQuery SlideUp 和 SlideDown。 http://ourrecipes.mdssoftware.com.au/ 在 IE 中这工作得很好。但在 Chrome
我的网站上有一个 SlideDown 功能。但不知怎的,当你第一次点击它时它不起作用。所以我需要点击两次才能使该功能起作用。什么可能是错误的? 我还希望当我再次点击按钮时div向上滑动,不知道我将如何
这应该很容易,但我检查了谷歌并没有找到任何相关信息。 我正在做: $notification.slideDown(1000, function(){ $('#n
为什么这个 jQuery 代码不起作用? $(document).ready(function () { $('currentPage').click(function() {
我们什么时候应该使用 jQuery 中的 slideUp/slideDown 以及什么时候使用 slideToggle 函数?slidetoggle 在 IE 中工作是否有问题? 最佳答案 当您想要向
我正在使用 jquery 制作一个向下滑动的菜单。该代码在页面第一次加载时完美运行。但是,slideDown(单击功能的基本部分)对于每个菜单项只能运行一次。这是一个 js fiddle 示例 htt
大家好。我有一点问题。我有一个有序列表,其中包含一系列预先填充的列表项。 Item 1 Item 2 Item 3 Item 4 当我使用 jQuery 动态添加另
我希望有人能帮助我正确完成这项工作。 我有这个 HTML: 1 view modules
我想知道是否有任何方法可以使 SlideDown() 移动看起来更平滑,而无需使用 jQuery UI,只需使用普通的 jquery。 我有这个功能: function optionz(){
我正在尝试构建一个具有动态高度和数量的元素列表,当用户单击它们时,这些元素会上下滑动。问题是,当时只需要显示其中一个,而其他的则在点击后会自动向上滑动。 我遇到了位于正在滑下的元素下方的元素的问题。它
我在 profile.php 中有一个可用的 slideDown div。当我单击用户名时,个人资料信息会向下滑动。这是结构, profile.php - 这工作正常。 $('.showprofile
我目前正在创建一个简单的菜单,其中有多个服务名称,用户可以单击其中一个,jQuery 将在其下方显示相应的描述段落。我的 jQuery 代码很好,完全符合我的要求,但是,我有一个错误尚未解决。 每当我
因此,当与 jQuery slideDown 函数结合使用时,我的渐变会出现令人讨厌的样式现象。 我怀疑正在发生的事情是我在每个页面上都运行了一个全局渐变。在一页上我使用以下内容: function
我是一名优秀的程序员,十分优秀!