简体   繁体   English

Bootstrap手风琴-页面首先跳至底部,然后跳至第一期

[英]Bootstrap Accordion - Page jumps to bottom first then go to top issue

When I click on accordion tab, it goes to bottom of the page due to difference in amount of content and height of the content. 当我单击手风琴选项卡时,由于内容量和内容高度的差异,它会转到页面底部。

I used this code to send page to top, but its scroll the page to bottom first then animate it to the top, which looks weird. 我使用此代码将页面发送到顶部,但首先将页面滚动到底部,然后将其设置为顶部动画,这看起来很奇怪。

$('#accordion').on('shown.bs.collapse', function () {
    window.elenow = $(this);
    $("html, body").animate({ scrollTop: $(window.elenow).offset().top }, 500);
});

I just want to page remain still when click on accordion tab, no go to top no go to bottom, just stay where its clicked. 我只想在单击手风琴选项卡时使页面保持静止,不移至顶部,不移至底部,仅停留在其单击的位置。

You can prevent scrolling all together by changing your href to href="javascript:void(0);" 您可以通过将href更改为href="javascript:void(0);"来防止全部滚动href="javascript:void(0);"

Here is a fiddle that shows the example. 这是显示示例的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM