国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

Bootstrap Scrollspy源碼學習

2024-05-06 15:10:28
字體:
來源:轉載
供稿:網友

本文實例為大家分享了Bootstrap Scrollspy插件的具體代碼,供大家參考,具體內容如下

導航欄Scrollspy例子

<!-- The scrollable area --><body data-spy="scroll" data-target=".navbar" data-offset="50"><!-- The navbar - The <a> 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"> <li><a href="#section1" rel="external nofollow" rel="external nofollow" >Section 1</a></li> ...</nav><!-- Section 1 --><div id="section1"> <h1>Section 1</h1> <p>Try to scroll this page and look at the navigation bar while scrolling!</p></div>...</body>

垂直Scrollspy例子

<body data-spy="scroll" data-target="#myScrollspy" data-offset="20"> <div class="container"> <div class="row">  <nav class="col-sm-3" id="myScrollspy">  <ul class="nav nav-pills nav-stacked">   <li><a href="#section1" rel="external nofollow" rel="external nofollow" >Section 1</a></li>   ...  </ul>  </nav>  <div class="col-sm-9">  <div id="section1">    <h1>Section 1</h1>   <p>Try to scroll this page and look at the navigation list while scrolling!</p>  </div>   ...  </div> </div> </div></body>

Scrollspy的使用

使用Scrollspy只需在對應的HTML元素里添加幾個關鍵的屬性:
- data-spy=”scroll”
添加到需要滾動的元素中,比如最常見的body元素,或者container。
- data-target=”selector”
添加到需要滾動的元素中,selector指示的是控制滾動的元素比如”.navbar”, “#myScrollspy”。
- <a href=”#section”>section</a>
在控制滾動的元素中用link鏈接到對應的位置。注意鏈接的id要跟對應位置元素的id相匹配。例如,<div id=”section1”>與<a href=”#seciton1”。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 邮箱| 军事| 滦平县| 怀柔区| 台北市| 绥江县| 陕西省| 定安县| 蚌埠市| 崇明县| 长沙市| 碌曲县| 河西区| 鲁甸县| 虞城县| 潞城市| 灵武市| 洛浦县| 仪陇县| 廉江市| 霸州市| 昌邑市| 广西| 喀喇沁旗| 金湖县| 明光市| 抚顺市| 宝应县| 沁水县| 阿拉善左旗| 依安县| 青川县| 凯里市| 玉龙| 开化县| 海安县| 平果县| 郁南县| 永平县| 托里县| 墨江|