Skip to content

Commit

Permalink
feat: add toTop button 添加返回顶部按钮
Browse files Browse the repository at this point in the history
Put a toTop button on the right for quick scrolling.
在页面右边加了个返回顶部按钮便于页面跳转。

http://www.cnblogs.com/jingangel/archive/2012/03/08/2385939.html
  • Loading branch information
MOxFIVE committed Aug 22, 2015
1 parent e29de4b commit c1a3786
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions themes/Yilia/layout/_partial/article.ejs
Expand Up @@ -48,6 +48,17 @@
} }
} }
</script> </script>
<div id="toTop"></div>
<script>
window.onload = function(){
var to_top = document.getElementById("toTop");
to_top.onclick = function(){
document.documentElement.scrollTop = document.body.scrollTop =0;
}
}
</script>
<%- post.content %> <%- post.content %>
<% } %> <% } %>
</div> </div>
Expand Down
19 changes: 19 additions & 0 deletions themes/Yilia/source/css/_partial/article.styl
Expand Up @@ -396,4 +396,23 @@
} }
#toc .toc-child { #toc .toc-child {
padding-left: 1.25em padding-left: 1.25em
}

#toTop{
display:block;
padding:0.05em;
border-radius:0.15em;
width:1.1em;
height:1.4em;
line-height:1.3em;
font-size:1.5em;
font-family: Calibri;
text-align: center;
background:lightgray;
position: fixed;
cursor: pointer;
color: #fff;
top: 40%;
right: 1px;
opacity:0.6;
} }

0 comments on commit c1a3786

Please sign in to comment.