如何創(chuàng)建Magellan導(dǎo)航
Magellan導(dǎo)航是一個固定位置的導(dǎo)航索引,它會根據(jù)用戶滾動到當前展示內(nèi)容自動切換導(dǎo)航項。創(chuàng)建Magellan導(dǎo)航的方式如下: 在包含導(dǎo)航的元素上添加data-magellan-expedit
Magellan導(dǎo)航是一個固定位置的導(dǎo)航索引,它會根據(jù)用戶滾動到當前展示內(nèi)容自動切換導(dǎo)航項。創(chuàng)建Magellan導(dǎo)航的方式如下:
- 在包含導(dǎo)航的元素上添加data-magellan-expedition"fixed"屬性。
- 在每個需要導(dǎo)航的地方(如
- 或
- )上添加data-magellan-arrival"value"屬性,后面添加與該屬性值相同的鏈接(如page1)。
- 使用data-magellan-destination"value"屬性來控制導(dǎo)航目標的位置,在緊跟這個目標的元素上添加name"value"屬性。
- 最后,初始化Foundation JS,當用戶滾動頁面時,導(dǎo)航將會根據(jù)當前顯示的內(nèi)容自動切換。
使用Magellan導(dǎo)航頭部工具條
Magellan導(dǎo)航可以和頭部工具條結(jié)合使用,實現(xiàn)更靈活的導(dǎo)航效果。使用頭部工具條的方法如下:
lt;div data-magellan-expedition"fixed"gt; lt;nav class"top-bar" data-topbargt; lt;section class"top-bar-section"gt; lt;ul class"left"gt; lt;li data-magellan-arrival"page1"gt;lt;a href"#page1"gt;Page 1lt;/agt;lt;/ligt; lt;li data-magellan-arrival"page2"gt;lt;a href"#page2"gt;Page 2lt;/agt;lt;/ligt; lt;/ulgt; lt;/sectiongt; lt;/navgt; lt;/divgt;在上面的代碼中,我們將Magellan導(dǎo)航和Foundation的頭部工具條結(jié)合起來。只需按照上述步驟創(chuàng)建Magellan導(dǎo)航,并將導(dǎo)航項添加到頭部工具條的
- 中即可。
修改Magellan導(dǎo)航的內(nèi)邊距
默認情況下,Magellan導(dǎo)航的
元素有10px的內(nèi)邊距。如果需要移除這個內(nèi)邊距,可以使用以下CSS代碼:[data-magellan-expedition], [data-magellan-expedition-clone] { padding: 0; }通過以上CSS代碼,可以將Magellan導(dǎo)航的內(nèi)邊距設(shè)為0。
使用data-options屬性修改Magellan導(dǎo)航設(shè)置
通過使用data-options屬性,可以修改Magellan導(dǎo)航的一些設(shè)置。例如:
lt;div data-magellan-expedition"fixed" data-options"destination_threshold:60"gt;...在上述代碼中,我們使用data-options屬性來設(shè)置destination_threshold的值為60。這個值用于控制滾動到目標位置前的偏移量。
如果本經(jīng)驗對你有所幫助,請給予我們點贊并投上寶貴的一票。感謝您的支持!
- 在每個需要導(dǎo)航的地方(如