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

时间:2014-05-12 19:24:01

标签: twitter-bootstrap-3 accordion collapsable

我有一个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 :(得分:0)

如果您使用带有锚链接的href标记,那么会导致您跳转到页面顶部导致不需要的行为。您需要在点击

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

See this article

希望这是正确答案。