css3文章右邊的TOC菜單是怎么實現(xiàn)的
問題描述
RT,就比如這篇文章CSS3打造3D立方體 在Github找到一個toc但是不支持中文,例如我二級標題是中文的話,生成的toc菜單定位到文中就錯誤。 謝謝各位~
問題解答
回答1:根據(jù)正文的h1、h2、h3等不同層級,使用js來實現(xiàn)的。和標題是不是中文應(yīng)該沒關(guān)系。你找到的那個toc就支持中文。我試過了。
回答2:它是以id來定位的。
如果只看文檔的話,應(yīng)該是
$(’#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();}});
相關(guān)文章:
1. 關(guān)docker hub上有些鏡像的tag被標記““This image has vulnerabilities””2. Span標簽3. css - 求推薦適用于vue2的框架 像bootstrap這種類型的4. docker-machine添加一個已有的docker主機問題5. android新手一枚,android使用httclient獲取服務(wù)器端數(shù)據(jù)失敗,但是用java工程運行就可以成功獲取。6. css - 關(guān)于div自適應(yīng)問題,大家看圖吧,說不清7. angular.js使用$resource服務(wù)把數(shù)據(jù)存入mongodb的問題。8. java - Collections類里的swap函數(shù),源碼為什么要新定義一個final的List型變量l指向傳入的list?9. python - django如何每次調(diào)用標簽的時候都取隨機數(shù)據(jù)10. SessionNotFoundException:會話ID為null。調(diào)用quit()后使用WebDriver嗎?(硒)
