change table of contents

This commit is contained in:
liuboaibc 2020-06-19 15:19:54 +08:00
parent 90b8aef649
commit 311e945e15
2 changed files with 30 additions and 8 deletions

View File

@ -149,21 +149,25 @@
}
.tabs {
li {
margin: 4px 0;
font-size: 16px;
#TableOfContents > ul > li > a {
font-weight: 500;
}
li {
margin: 10px 0;
font-size: 16px;
line-height: 2;
color: #36435c;
a {
display: block;
width: 100%;
height: 32px;
font-weight: 400;
line-height: 24px;
color: #36435c;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
&:hover {
color: #55bc8a;
}
}
}
li li {

View File

@ -24,4 +24,22 @@ var bindAsideScroll = function() {
}
});
}
bindAsideScroll()
var bindClickLink = function() {
var aside = $('.aside')
var headerHeight = $('header').outerHeight()
aside.find('a').click(function(event) {
event.preventDefault()
var id = $(this).attr('href')
scrollToElement(id, headerHeight)
})
}
var scrollToElement = function(id, headerHeight) {
var element = $(id)
var toTop = element.offset().top
window.scrollTo(0, toTop - headerHeight)
}
bindAsideScroll()
bindClickLink()