首页 文章

Bootstrap 3只能与锚点一起使用 - 导致滚动

提问于
浏览
0

我有一个bootstrap 3手风琴

<dl class="panel-group col-lg-10 col-lg-offset-1" id="product-list">
  <dt class="panel-heading col-lg-12">
      <a data-toggle="collapse" data-parent="product-list" href="collapseOne">  
        <h3 class="panel-title">
          Heading Content
        </h3>
      </a>
  </dt>
  <dd id="collapseOne" class="product-details panel-collapse collapse col-lg-12">
        Collapsable Content
    </dd>
</dl>

这个标记的工作原理是手风琴可以正常打开和关闭 . 但是,它在DD的打开和关闭时滚动到锚点 . 这不是我想要的行为 .

我已经尝试将锚标签更改为div,但这会打破我的手风琴 . 只有当我放入一个锚点击时,才会打开不同的可折叠部分 .

1 回答

  • 0

    如果您正在使用带有锚链接的href标记,那么这将导致您跳转到页面顶部导致不需要的行为 . 您需要在点击时禁用JavaScript

    <a href="javascript:void(0)" id="loginlink">login</a>
    

    See this article

    希望这是正确的答案 .

相关问题