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. html5 - 求详解h5 video事件监听2. android - webview 自定义加载进度条3. jupyter-notebook - Mac下启动jupyter notebook后没有Python的选项?4. Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?5. 输入地址报以下截图错误,怎么办?6. javascript - vue更改当前节点元素7. vue.js - vue 打包后 nginx 服务端API请求跨域问题无法解决。8. angular.js - angular post的Content-Type被设置,导致不能上传图片,求助!!9. css3 - 这个效果用 CSS 可以实现吗?border-image10. http - nginx 反向代理 url 错误

网公网安备