Skip to content

Commit b798f3e

Browse files
feat: 添加画廊布局和样式,优化图片展示效果
Signed-off-by: wangsimiao1 <wangsimiao1@xiaomi.com>
1 parent 91a9690 commit b798f3e

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

_sass/pages/_gallery.scss

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@use '../abstracts/variables' as v;
2+
@use '../abstracts/breakpoints' as bp;
3+
4+
.gallery-grid {
5+
display: grid;
6+
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
7+
gap: 1.25rem;
8+
margin-top: 1.5rem;
9+
10+
.g-item {
11+
position: relative;
12+
z-index: 1;
13+
cursor: pointer;
14+
border-radius: v.$radius-lg;
15+
overflow: hidden;
16+
background: var(--card-bg);
17+
box-shadow: var(--card-shadow);
18+
opacity: 0;
19+
animation: card-enter 0.6s v.$ease-spring-soft forwards;
20+
transition: transform 0.4s v.$ease-spring,
21+
box-shadow 0.4s v.$ease-spring-soft;
22+
23+
@for $i from 1 through 30 {
24+
&:nth-child(#{$i}) {
25+
animation-delay: #{($i - 1) * 0.06}s;
26+
}
27+
}
28+
29+
&:hover {
30+
transform: translateY(-4px);
31+
box-shadow: 0 8px 24px rgb(120 110 100 / 12%);
32+
33+
img {
34+
transform: scale(1.05);
35+
}
36+
}
37+
38+
img {
39+
width: 100%;
40+
display: block;
41+
transition: transform 0.5s v.$ease-spring;
42+
}
43+
}
44+
}

_sass/pages/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
@forward 'archives';
77
@forward 'category-tag';
88
@forward 'card-grid';
9+
@forward 'gallery';

_tabs/gallery.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ order: 5
55
---
66

77
<style>
8-
.g-item { margin-bottom: 12px; cursor: pointer; }
9-
.g-item img { width: 100%; border-radius: 6px; display: block; }
108
.lb { display:none; position:fixed; inset:0; z-index:9999; background:rgba(0,0,0,0.9); justify-content:center; align-items:center; }
119
.lb.on { display:flex; }
1210
.lb img { max-width:92vw; max-height:90vh; border-radius:6px; }
@@ -19,11 +17,13 @@ order: 5
1917
</div>
2018

2119
{% if site.data.gallery.size > 0 %}
20+
<div class="gallery-grid">
2221
{% for photo in site.data.gallery %}
2322
<div class="g-item" onclick="openLB('{{ photo.image }}')">
2423
<img src="{{ photo.image }}" alt="照片" loading="lazy" />
2524
</div>
2625
{% endfor %}
26+
</div>
2727
{% else %}
2828
<p class="text-muted text-center mt-5">📷 还没有照片</p>
2929
{% endif %}

0 commit comments

Comments
 (0)