css3文章右邊的TOC菜單是怎么實現的
問題描述
RT,就比如這篇文章CSS3打造3D立方體 在Github找到一個toc但是不支持中文,例如我二級標題是中文的話,生成的toc菜單定位到文中就錯誤。 謝謝各位~
問題解答
回答1:根據正文的h1、h2、h3等不同層級,使用js來實現的。和標題是不是中文應該沒關系。你找到的那個toc就支持中文。我試過了。
回答2:它是以id來定位的。
如果只看文檔的話,應該是
$(’#toc’).toc({ ’selectors’: ’h1,h2,h3’, //elements to use as headings ’container’: ’body’, //element to find all selectors in ’smoothScrolling’: true, //enable or disable smooth scrolling on click ’prefix’: ’toc’, //prefix for anchor tags and class names <----------此處生成id ’onHighlight’: function(el) {}, //called when a new section is highlighted ’highlightOnScroll’: true, //add class to heading that is currently in focus ’highlightOffset’: 100, //offset to trigger the next headline ’anchorName’: function(i, heading, prefix) { //custom function for anchor namereturn prefix+i; }, ’headerText’: function(i, heading, $heading) { //custom function building the header-item textreturn $heading.text(); },’itemClass’: function(i, heading, $heading, prefix) { // custom function for item class return $heading[0].tagName.toLowerCase();}});
相關文章:
1. javascript - vuejs+elementui 購物車價格計算,點擊加減號修改數量總價都不會改變,但是計算執行了2. css右浮動字的順序顛倒了3. php - 請問大批量數據處理,如何分割?4. MySQL主鍵沖突時的更新操作和替換操作在功能上有什么差別(如圖)5. javascript - 我是做web前端的,公司最近有一個項目關于數據統計的!6. ios - 類似微博首頁,一張圖的時候是如何確定圖大小的?7. javascript - 如何使用loadash對[object,object,object]形式的數組進行比較8. javascript - vue過渡效果 css過渡 類名的先后順序9. html5和Flash對抗是什么情況?10. 數據庫 - Mysql的存儲過程真的是個坑!求助下面的存儲過程哪里錯啦,實在是找不到哪里的問題了。
