Bootstrap accordion scrolling behaviour on collapse

前端 未结 3 1072
暗喜
暗喜 2021-02-14 02:18

I am using Bootstrap 3 accordion. After reading numerous posts on how to have independent behaviour on the contents, rather than keeping only one active by default, i use

相关标签:
3条回答
  • 2021-02-14 02:42

    In my case I was using button just changed it to div.

    0 讨论(0)
  • 2021-02-14 02:54

    Just add class="your-header-class" to the a header element:

    <a class="your-header-class" data-toggle="collapse" data-content="#your-content" href="#your-content">...</a>
    

    and then add this:

    $('.your-header-class').click(function(e) {
        e.preventDefault();
    })
    
    0 讨论(0)
  • 2021-02-14 03:09

    I think i know what causes the scrolling problem. If you are based on the example shown in getbootstrap.com, then you probably use anchors

    <a data-toggle="collapse" data-content="#your-content" href="#your-content">...</a>
    

    instead of anchors you can use spans

    <span data-toggle="collapse" data-content="#your-content">...<span>
    

    The href in the anchor is causing the scroll. I hope that helps

    0 讨论(0)
提交回复
热议问题