可扩展的bootstrap页脚

时间:2018-01-16 17:19:36

标签: jquery css twitter-bootstrap footer bootstrap-accordion

我试图通过使用手风琴在Bootstrap中制作可扩展的页脚。单击页脚时,我希望内容向上滑动并将其上方的部分向上推。目前,当点击时,所有内容都会向下滑动。任何帮助将非常感激。

以下是我正在使用的代码以及fiddle

<section class="red">
  <div class="container">
    <div class="row">
      <div class="col-lg-8 mx-auto">
        <p class="lead">Donec a lacinia turpis, ut auctor quam. Nam euismod elit et tortor tempus efficitur. Curabitur quis sapien id metus porta hendrerit vel nec libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras mattis, nibh eu egestas tempus, purus
          velit finibus tellus, vitae eleifend ante ex non orci. Aliquam id dolor eu odio finibus fermentum. Morbi nec luctus purus. Integer tincidunt odio eros, non fringilla tortor placerat quis. Praesent consectetur massa nibh, ac maximus ante viverra
          sodales. Nunc id velit eu nisi congue pulvinar sit amet in tellus. Proin sit amet tortor nec purus suscipit dictum id in lacus. Aliquam congue auctor felis ut fermentum.</p>
      </div>
    </div>
  </div>
</section>

<section class="yellow">
  <div class="container">
    <div class="row">
      <div class="col-lg-8 mx-auto">
        <p class="lead">Mauris finibus nibh in accumsan sodales. Vivamus interdum tempus nibh vel efficitur. Suspendisse potenti. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce suscipit eget turpis ac viverra. Donec
          imperdiet sem a leo elementum pulvinar. Donec scelerisque elit ipsum, non tristique libero tincidunt sed.</p>
      </div>
    </div>
  </div>
</section>

<section class="green">
  <div class="container">
    <div class="row">
      <div class="col-lg-8 mx-auto">
        <p class="lead">Suspendisse ac libero maximus, sollicitudin ligula a, tempus turpis. Duis cursus, felis nec molestie cursus, nibh quam laoreet elit, id fringilla velit leo nec neque. Aenean nibh neque, ultricies non tortor non, lacinia suscipit nulla. Quisque
          in ultrices ante. Ut dignissim, urna ut egestas ornare, nulla erat accumsan augue, at fermentum libero eros semper ligula. Phasellus efficitur eros ac leo posuere, ultrices venenatis risus rutrum. Nullam facilisis volutpat pellentesque.</p>
      </div>
    </div>
  </div>
</section>

<!-- Footer -->
<footer>
  <div class="container-fluid p-0">
    <div class="panel-group" id="accordion">
      <div class="panel panel-default">
        <div class="panel-heading">
          <p class="panel-title m-0">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
                  &#x2191;
                </a>
          </p>
        </div>
        <div id="collapseOne" class="panel-collapse collapse">
          <div class="panel-body">
            <div class="row">
              <div class="col-md-6 offset-md-3 align-self-center">
                Cras id ex quis sapien condimentum aliquet a vitae turpis. In imperdiet magna maximus nunc ultricies maximus. Donec congue lobortis ante, quis convallis purus iaculis sit amet.Cras id ex quis sapien condimentum aliquet a vitae turpis. In imperdiet magna
                maximus nunc ultricies maximus. Donec congue lobortis ante, quis convallis purus iaculis sit amet. Cras id ex quis sapien condimentum aliquet a vitae turpis. In imperdiet magna maximus nunc ultricies maximus. Donec congue lobortis ante,
                quis convallis purus iaculis sit amet.
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- /.container -->
</footer>

解决方案:

$("#collapseOne").on("show.bs.collapse", function() {
$("html, body").animate({ scrollTop: 999999 }, "slow");

});

fiddle

2 个答案:

答案 0 :(得分:0)

@reidb你只需要改变标题和正文的位置。请遵循以下代码:

<div class="container-fluid p-0">
    <div class="panel-group" id="accordion">
      <div class="panel panel-default">

        <div id="collapseOne" class="panel-collapse collapse">
          <div class="panel-body">
            <div class="row">
              <div class="col-md-6 offset-md-3 align-self-center">
                Cras id ex quis sapien condimentum aliquet a vitae turpis. In imperdiet magna maximus nunc ultricies maximus. Donec congue lobortis ante, quis convallis purus iaculis sit amet.Cras id ex quis sapien condimentum aliquet a vitae turpis. In imperdiet magna
                maximus nunc ultricies maximus. Donec congue lobortis ante, quis convallis purus iaculis sit amet. Cras id ex quis sapien condimentum aliquet a vitae turpis. In imperdiet magna maximus nunc ultricies maximus. Donec congue lobortis ante,
                quis convallis purus iaculis sit amet.
              </div>
            </div>
          </div>
        </div>

        <div class="panel-heading">
          <p class="panel-title m-0">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
                  &#x2191;
                </a>
          </p>
        </div>
      </div>
    </div>
  </div>

答案 1 :(得分:0)

<强>解决方案:

$("#collapseOne").on("show.bs.collapse", function() {
    $("html, body").animate({ scrollTop: $(document).height() }, "slow");
});

fiddle