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. $fields = $values = [];这条代码一直定义不了,一直报错,老师的源码也是被报错的,执行不了,请问该怎么解决这个问题2. python - 求一个在def中可以实现调用本def满足特定条件continue效果的方法(标题说不太清楚,请见题内描述)3. mysql - SQL操作时间的函数?4. javascript - 用表单提交两个时间段请求后台返回对应数据时出现的一些问题!5. MYSQL新建用户设置可以远程访问的问题6. java - mybatis怎么实现在数据库中有就修改,没有就添加7. angular.js - angularjs的自定义过滤器如何给文字加颜色?8. node.js - nodejs和前端JavaScript 字符串处理结果不一样是什么原因?9. docker-compose中volumes的问题10. docker api 开发的端口怎么获取?
![$fields = $values = [];这条代码一直定义不了,一直报错,老师的源码也是被报错的,执行不了,请问该怎么解决这个问题](http://www.haobala.com/attached/image/news/202205/093622cb60.png)