Bootstrap Scrollspy源码学习

本文实例为大家分享了Bootstrap Scrollspy插件的具体代码,供大家参考,具体内容如下

导航栏Scrollspy例子

rush:xhtml;"> elements are used to jump to a section in the scrollable area -->

<nav class="navbar navbar-inverse navbar-fixed-top">
...
<ul class="nav navbar-nav">

  • Section 1
  • ...

    <div id="section1">

    Section 1

    Try to scroll this page and look at the navigation bar while scrolling!

    ...

    垂直Scrollspy例子

    rush:xhtml;"> <div class="container">
    <div class="row">
    <nav class="col-sm-3" id="myScrollspy">
    <ul class="nav nav-pills nav-stacked">

  • Section 1
  • ...
    Section 1

    Try to scroll this page and look at the navigation list while scrolling!

    ...

    Scrollspy的使用

    使用Scrollspy只需在对应的HTML元素里添加几个关键的属性添加到需要滚动的元素中,比如最常见的body元素,或者container。 添加到需要滚动的元素中,selector指示的是控制滚动的元素比如”.navbar”,“#myScrollspy”。 section 在控制滚动的元素中用link链接到对应的位置。注意链接的id要跟对应位置元素的id相匹配。例如,

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

    相关文章

    Bootstrip HTML 查询搜索常用格式模版 &lt;form class=&...
    如何在按钮上加红色数字 您可以使用Bootstrap的badge组件来在...
    要让两个按钮左右排列,你可以使用 Bootstrap 的网格系统将它...
    是的,可以将status设置为布尔类型,这样可以在前端使用复选...
    前端工程师一般用的是Bootstrap的框架而不是样式,样式一般自...
    起步导入:<linkrel="stylesheet"href="b...