Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion css/default.css
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ fieldset,img,a img{border:0;}
iframe{display:block;}
abbr,acronym{border:0;font-variant:normal;}
del{text-decoration:line-through;}
address,caption,cite,code,dfn,em,th,var {font-style:normal;font-weight:500;}
address,caption,cite,code,dfn,th,var {font-style:normal;font-weight:500;}
ol,ul {list-style:none;}
caption,th{text-align:left;}
h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:500;}
Expand DownExpand Up@@ -63,6 +63,7 @@ pre ol{margin-left:25px;list-style-type:decimal;}
.sidenav a { color:#555; font-size:14px; display:block;}
.entry{margin-bottom:80px;width:680px; float:left; background:#fff; padding:30px; box-shadow:0 2px 6px #ccc; }
.entry ul{margin-bottom:25px;margin-left:25px;}
.entry ul ul{margin-bottom:0;}
.entry p+ul {margin-top:-20px;}
.entry ul li{margin-bottom:5px;list-style:disc;line-height:1.8em;}
.entry ol{margin-bottom:25px;margin-left:25px;}
Expand DownExpand Up@@ -183,3 +184,9 @@ h3.about {color:#777;margin-top:20px;font-size:22px;margin-bottom:10px}
@media (max-width: 1300px){
.home-menu { position:absolute; }
}

@media screen and (min-width: 1380px) {
#content {width:80%;}
.sidenav {width:22%;}
.entry {width:65%;}
}
23 changes: 16 additions & 7 deletions js/post.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -74,6 +74,9 @@ $(document).ready(function(){
item.id = 'menuIndex' + index;
});

// add back to top
h2.push({name: '回到顶部', id: 'top'});

return {h2:h2,h3:h3}
}

Expand All@@ -86,7 +89,7 @@ $(document).ready(function(){
var h3 = heading.h3;

for(var i=0;i<h2.length;i++){
tmpl += '<li><a href="#" data-id="'+h2[i].id+'">'+h2[i].name+'</a></li>';
tmpl += '<li class="h2"><a href="#" data-id="'+h2[i].id+'">'+h2[i].name+'</a></li>';

if(h3[i]){
for(var j=0;j<h3[i].length;j++){
Expand All@@ -111,9 +114,9 @@ $(document).ready(function(){
e.preventDefault();

var selector = $(this).attr('data-id') ? '#'+$(this).attr('data-id') : 'h1'
var scrollNum = $(selector).offset().top;
var scrollNum = (selector == '#top') ? 0 : $(selector).offset().top - 30;

$('body, html').animate({scrollTop: scrollNum-30 }, 400, 'swing');
$('body, html').animate({scrollTop: scrollNum}, 400, 'swing');
});
}

Expand All@@ -138,12 +141,15 @@ $(document).ready(function(){
var scrollTop = [];
$.each($('#menuIndex li a'),function(index,item){
var selector = $(item).attr('data-id') ? '#'+$(item).attr('data-id') : 'h1'
var top = $(selector).offset().top;
scrollTop.push(top);
if (selector != '#top') {
var top = $(selector).offset().top;
scrollTop.push(top);
}
});

var menuIndexTop = $('#menuIndex').offset().top;
var menuIndexLeft = $('#menuIndex').offset().left;
var menuIndexWidth = ($(window).width() < 1380) ? $('#menuIndex').width() : $('#content').width() * 0.22;

$(window).scroll(function(){
waitForFinalEvent(function(){
Expand All@@ -156,6 +162,7 @@ $(document).ready(function(){
position:'fixed'
,top:'20px'
,left:menuIndexLeft
,width:menuIndexWidth
});
}else{
$('#menuIndex').css({
Expand All@@ -175,8 +182,10 @@ $(document).ready(function(){
}
}
}
$('#menuIndex li').removeClass('on');
$('#menuIndex li').eq(index-1).addClass('on');
if (index > 0) {
$('#menuIndex li').removeClass('on');
$('#menuIndex li').eq(index-1).addClass('on');
}
});
});

Expand Down