Skip to content

Commit 4cbb514

Browse files
committed
Merge branch 'dev'
2 parents 65f9382 + cd964e7 commit 4cbb514

File tree

12 files changed

+83
-10
lines changed

12 files changed

+83
-10
lines changed

_includes/backToTop.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="back-to-top">
2+
<a href="#top" class="scroll">
3+
<i class="fa fa-arrow-up" aria-hidden="true"></i>
4+
</a>
5+
</div>

_includes/footer.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@
2929
</div>
3030
</footer>
3131
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
32-
<script src="{{ " /js/main.js " | prepend: site.baseurl }}" charset="utf-8"></script>

_includes/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<header>
1+
<header id="top">
22
<div class="wrapper">
33
<a href="{{ site.baseurl }}/" class="brand">{{ site.title }}</a>
44
<small>{{site.brief-intro}}</small>

_layouts/default.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
{{ content }}
1111

1212
{% include footer.html %}
13-
13+
{% include backToTop.html %}
14+
<script src="{{ " /js/main.js " | prepend: site.baseurl }}" charset="utf-8"></script>
15+
<script src="{{ " /js/scroll.min.js " | prepend: site.baseurl }}" charset="utf-8"></script>
1416
</body>
1517

1618
</html>

_layouts/page.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ <h1>{{page.title}}</h1>
2525
</div>
2626
</div>
2727
</div>
28-
<script src="{{ "/js/scroll.min.js " | prepend: site.baseurl }}" charset="utf-8"></script>
2928
<script src="{{ "/js/pageContent.js " | prepend: site.baseurl }}" charset="utf-8"></script>

_layouts/post.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,10 @@ <h2 id="comments">Comments</h2>
9191
* target _blank
9292
*/
9393
(function() {
94-
var aTags = document.querySelectorAll('article a')
94+
var aTags = document.querySelectorAll('article a:not([id])')
9595
for (var i = 0; i < aTags.length; i++) {
9696
aTags[i].setAttribute('target', '_blank')
9797
}
9898
}());
9999
</script>
100-
<script src="{{ "/js/scroll.min.js " | prepend: site.baseurl }}" charset="utf-8"></script>
101100
<script src="{{ "/js/pageContent.js " | prepend: site.baseurl }}" charset="utf-8"></script>

_sass/_backToTop.scss

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.back-to-top {
2+
position: fixed;
3+
left: 50%;
4+
margin-left: 580px;
5+
bottom: 37px;
6+
background-color: #f8f8fd;
7+
visibility: hidden;
8+
opacity: 0;
9+
transition: 0.4s ease;
10+
box-shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.3), 0 0 30px rgba(10, 10, 0, 0.1) inset;
11+
a {
12+
display: block;
13+
background-color: #eee;
14+
width: 38px;
15+
height: 38px;
16+
line-height: 38px;
17+
text-align: center;
18+
font-size: 20px;
19+
color: #b4b4b4;
20+
}
21+
}
22+
.back-to-top-show{
23+
visibility: visible;
24+
opacity: 0.7;
25+
}
26+
@media screen and (max-width:1200px) and (min-width: 770px) {
27+
.back-to-top {
28+
left: 50%;
29+
margin-left: 45.5%;
30+
}
31+
}
32+
@media screen and (max-width: 770px) {
33+
.back-to-top {
34+
right:2.5%;
35+
left: auto;
36+
// left: 50%;
37+
margin-left: 0px;
38+
a {
39+
width: 33px;
40+
height: 33px;
41+
line-height: 33px;
42+
text-align: center;
43+
font-size: 18px;
44+
}
45+
}
46+
}

css/main.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
"index",
5858
"demo",
5959
"footer",
60-
"scrollbar"
60+
"scrollbar",
61+
"backToTop"
6162
;
6263

6364
// 两个人在列车上相遇

js/main.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,28 @@
2727
})
2828
}
2929
}());
30+
31+
32+
//////////////////////////back to top////////////////////////////
33+
(function() {
34+
var backToTop = document.querySelector('.back-to-top')
35+
var backToTopA = document.querySelector('.back-to-top a')
36+
// console.log(backToTop);
37+
window.addEventListener('scroll',function () {
38+
39+
40+
// 页面顶部滚进去的距离
41+
var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop)
42+
43+
if (scrollTop > 200) {
44+
backToTop.classList.add('back-to-top-show')
45+
} else {
46+
backToTop.classList.remove('back-to-top-show')
47+
}
48+
})
49+
50+
// backToTopA.addEventListener('click',function (e) {
51+
// e.preventDefault()
52+
// window.scrollTo(0,0)
53+
// })
54+
}());

page/0archives.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,4 @@ <h2 id="y{{ post.date | date: '%Y' }}">{{ post.date | date: '%Y' }}</h2>
6565
</div>
6666
</div>
6767
</div>
68-
<script src="{{ "/js/scroll.min.js " | prepend: site.baseurl }}" charset="utf-8"></script>
6968
<script src="{{ "/js/pageContent.js " | prepend: site.baseurl }}" charset="utf-8"></script>

0 commit comments

Comments
 (0)