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. mac里的docker如何命令行开启呢?2. html5 - H5图片模糊处理3. javascript - 急, 自己的主机ip被别人域名绑定了,如何解决??4. html5 - Vue.js是由前端框架变成全栈框架了么?另外和express现在有什么区别?5. 求救一下,用新版的phpstudy,数据库过段时间会消失是什么情况?6. vue添加锚点,实现滚动页面时锚点添加相应的class操作7. ddos - apache日志很多其它网址,什么情况?8. boot2docker无法启动9. html - rtmp摄像头是个什么东西,怎么用?10. css - 设置font-family全局字体对网页布局会产生影响?
