Skip to content

Commit

Permalink
2024/04/20,00:00
Browse files Browse the repository at this point in the history
  • Loading branch information
Kicamon committed Apr 19, 2024
1 parent 78b05ee commit c053774
Show file tree
Hide file tree
Showing 27 changed files with 368 additions and 1 deletion.
2 changes: 2 additions & 0 deletions css/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@
font-weight: 900;
color: pink;
text-decoration: none;
margin-left: 1%;
margin-right: 1%;
}
183 changes: 183 additions & 0 deletions css/timeline.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
* {
padding: 0;
margin: 0;
}

.shell {
width: 100%;
position: relative;
padding: 80px 0;
transition: 0.3s ease 0s;
background-attachment: fixed;
background-size: cover;
}

.shell:before {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(99, 99, 99, 0.8);
content: "";
}

.header {
width: 100%;
text-align: center;
margin-bottom: 80px;
position: relative;
}

.title {
color: #fff;
font-size: 46px;
font-weight: normal;
margin: 0;
}

.timeline {
display: flex;
margin: 0 auto;
flex-wrap: wrap;
flex-direction: column;
max-width: 700px;
position: relative;
}

.content-title {
font-weight: normal;
font-size: 66px;
margin: -10px 0 0 0;
transition: 0.4s;
padding: 0 10px;
box-sizing: border-box;
color: #fff;
}

.content-desc {
margin: 0;
font-size: 15px;
box-sizing: border-box;
color: rgba(255, 255, 255, 0.7);
line-height: 25px;
}

.timeline:before {
position: absolute;
left: 50%;
width: 2px;
height: 100%;
margin-left: -1px;
content: "";
background: rgba(255, 255, 255, 0.07);
}

.item {
padding: 40px 0;
opacity: 0.3;
filter: blur(2px);
transition: 0.5s;
box-sizing: border-box;
width: calc(50% - 40px);
display: flex;
position: relative;
transform: translateY(-80px);
}

.item:before {
content: attr(data-text);
letter-spacing: 3px;
width: 100%;
position: absolute;
color: rgba(255, 255, 255, 0.5);
font-size: 13px;
border-left: 2px solid rgba(255, 255, 255, 0.5);
top: 70%;
margin-top: -5px;
padding-left: 15px;
opacity: 0;
right: calc(-100% - 56px);
font: 900 20px '';
letter-spacing: 5px;
}

.item:nth-child(even) {
align-self: flex-end;
}

.item:nth-child(even):before {
right: auto;
text-align: right;
left: calc(-100% - 56px);
padding-left: 0;
border-left: none;
border-right: 2px solid rgba(255, 255, 255, 0.5);
padding-right: 15px;
}

.item--active {
opacity: 1;
transform: translateY(0);
filter: blur(0px);
}

.item--active:before {
top: 50%;
transition: 0.3s all 0.2s;
opacity: 1;
}

.item--active .content-title {
margin: -50px 0 20px 0;
}

.img {
max-width: 100%;
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.4);
}

.subtitle {
color: rgba(255, 255, 255, 0.5);
font-size: 16px;
letter-spacing: 5px;
margin: 10px 0 0 0;
font-weight: normal;
}

.footer {
padding: 95px 0;
text-align: center;
}

.footer a {
color: #999;
display: inline-block;
}

@media only screen and (max-width: 767px) {
.item {
align-self: baseline !important;
width: 100%;
padding: 0 30px 150px 80px;
}

.item:before {
left: 10px !important;
padding: 0 !important;
top: 50px;
text-align: center !important;
width: 60px;
border: none !important;
}

.item:last-child {
padding-bottom: 40px;
}
}

@media only screen and (max-width: 767px) {
.timeline:before {
left: 40px;
}
}
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link href="css/nav.css" rel="stylesheet">
<link href="css/card.css" rel="stylesheet">
<link href="css/page.css" rel="stylesheet">
<script src="https://cdn.acwing.com/static/jquery/js/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>

<body>
Expand Down Expand Up @@ -38,6 +38,7 @@
</div>
<div class="jump">
<a href="./pages/clover.html">情书</a>
<a href="./pages/story.html">故事</a>
</div>
</div>

Expand Down
113 changes: 113 additions & 0 deletions pages/story.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>love</title>
<link href="../css/timeline.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>

<body>
<div class="shell" id="shell">
<div class="header">
<h2 class="title">小冷&允允</h2>
<h3 class="subtitle">我们的故事</h3>
</div>
<div class="timeline">
<div class="item" data-text="《执子之手,与子偕老》">
<div class="content">
<img src="../static/img-story/01.jpg" alt="" class="img">
<h2 class="content-title">2002</h2>
<p class="content-desc">
如果你停止,就是谷底。如果你还在继续,
就是上坡。这是我听过关于人生低谷最好的阐述。
</p>
</div>
</div>

<div class="item" data-text="《执子之手,与子偕老》">
<div class="content">
<img src="../static/img-story/02.jpg" alt="" class="img">
<h2 class="content-title">2002</h2>
<p class="content-desc">
如果你停止,就是谷底。如果你还在继续,
就是上坡。这是我听过关于人生低谷最好的阐述。
</p>
</div>
</div>

<div class="item" data-text="《执子之手,与子偕老》">
<div class="content">
<img src="../static/img-story/03.jpg" alt="" class="img">
<h2 class="content-title">2002</h2>
<p class="content-desc">
如果你停止,就是谷底。如果你还在继续,
就是上坡。这是我听过关于人生低谷最好的阐述。
</p>
</div>
</div>

<div class="item" data-text="《执子之手,与子偕老》">
<div class="content">
<img src="../static/img-story/04.jpg" alt="" class="img">
<h2 class="content-title">2002</h2>
<p class="content-desc">
如果你停止,就是谷底。如果你还在继续,
就是上坡。这是我听过关于人生低谷最好的阐述。
</p>
</div>
</div>

<div class="item" data-text="《执子之手,与子偕老》">
<div class="content">
<img src="../static/img-story/05.jpg" alt="" class="img">
<h2 class="content-title">2002</h2>
<p class="content-desc">
如果你停止,就是谷底。如果你还在继续,
就是上坡。这是我听过关于人生低谷最好的阐述。
</p>
</div>
</div>

<div class="item" data-text="《执子之手,与子偕老》">
<div class="content">
<img src="../static/img-story/06.jpg" alt="" class="img">
<h2 class="content-title">2002</h2>
<p class="content-desc">
如果你停止,就是谷底。如果你还在继续,
就是上坡。这是我听过关于人生低谷最好的阐述。
</p>
</div>
</div>

<div class="item" data-text="《执子之手,与子偕老》">
<div class="content">
<img src="../static/img-story/07.jpg" alt="" class="img">
<h2 class="content-title">2002</h2>
<p class="content-desc">
如果你停止,就是谷底。如果你还在继续,
就是上坡。这是我听过关于人生低谷最好的阐述。
</p>
</div>
</div>

<div class="item" data-text="《执子之手,与子偕老》">
<div class="content">
<img src="../static/img-story/08.jpg" alt="" class="img">
<h2 class="content-title">2002</h2>
<p class="content-desc">
如果你停止,就是谷底。如果你还在继续,
就是上坡。这是我听过关于人生低谷最好的阐述。
</p>
</div>
</div>
</div>
</div>

<script type="module" src="../scripts/timeline.js"></script>
</body>

</html>
68 changes: 68 additions & 0 deletions scripts/timeline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
(function ($) {
$.fn.timeline = function () {
let selectors = {
id: $(this),
item: $(this).find(".item"),
activeClass: "item--active",
img: ".img"
};
// 将第一个时间轴项目激活,并设置时间轴背景图片为第一个项目的图片
selectors.item.eq(0).addClass(selectors.activeClass);
selectors.id.css(
"background-image",
"url(" +
selectors.item.first()
.find(selectors.img)
.attr("src") +
")"
);
// 获取时间轴项目的总数
let itemLength = selectors.item.length;
// 当页面滚动时,触发滚动事件
$(window).scroll(function () {
let max, min;
// 获取页面滚动的距离
let pos = $(this).scrollTop();
selectors.item.each(function (i) {
// 获取当前时间轴项目的最小和最大高度
min = $(this).offset().top;
max = $(this).height() + $(this).offset().top;
let that = $(this);
// 如果滚动到最后一个项目,并且超过了当前项目高度的一半,
// 则将最后一个项目设置为激活状态,并设置背景图片为最后一个项目的图片
if (i == itemLength - 2 && pos > min + $(this).height() / 2) {
selectors.item.removeClass(selectors.activeClass);
selectors.id.css(
"background-image",
"url(" +
selectors.item.last()
.find(selectors.img)
.attr("src") +
")"
);
selectors.item.last().addClass(selectors.activeClass);
}
// 如果当前滚动位置在当前项目的最小和最大高度之间,
// 则将当前项目设置为激活状态,并设置背景图片为当前项目的图片
else if (pos <= max - 10 && pos >= min) {
selectors.id.css(
"background-image",
"url(" +
$(this)
.find(selectors.img)
.attr("src") +
")"
);
selectors.item.removeClass(selectors.activeClass);
$(this).addClass(selectors.activeClass);
}
});
});
};
})(jQuery)
/*
最后,我们调用 timeline 插件并传入时间轴的 ID 作为参数。
这将启用时间轴插件并为该时间轴绑定滚动事件。
*/
$("#shell").timeline();

Binary file added static/img-story/01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/03.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/04.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/05.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/06.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/07.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/08.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/09.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/13.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/14.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/15.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/16.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/18.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/19.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/20.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/21.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img-story/22.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c053774

Please sign in to comment.