Skip to content

Commit 3cd2913

Browse files
committed
隐藏滚动条宽度
1 parent 1451696 commit 3cd2913

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

public/styles/global.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
@import url("https://fontsapi.zeoseven.com/89/main/result.css");
2+
3+
/* Homepage specific styles, triggered by a class added via script */
4+
body.hide-scrollbar {
5+
background-color: #fffaf6;
6+
/* Hide scrollbar for IE, Edge and Firefox */
7+
-ms-overflow-style: none;
8+
scrollbar-width: 1px;
9+
}
10+
/* Hide scrollbar for Chrome, Safari and Opera */
11+
body.hide-scrollbar::-webkit-scrollbar {
12+
display: none;
13+
}
14+
215
body {
316
font-family: "JyunsaiKaai";
417
font-weight: normal;

src/pages/index.astro

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ const allPostsByDate = sortMDByDate(allPosts).slice(0, MAX_POSTS)
3131
<main class='flex w-full flex-col'>
3232
<!-- 第一屏 -->
3333
<div id='main-content' class='relative z-10 flex flex-col items-center px-4'>
34-
<!-- Rive Animation Block -->
3534
<!-- Motto Block -->
36-
<div class='relative z-10 mt-8 flex justify-center'>
35+
<div class='relative z-10 mt-16 flex justify-center'>
3736
<div
3837
class='inline-flex items-center gap-x-2 sm:gap-x-3 rounded-full border bg-background/80 px-3 py-1.5 sm:px-4 sm:py-2 text-xs sm:text-sm shadow-sm backdrop-blur transition-shadow hover:shadow-md'
3938
>
@@ -105,17 +104,13 @@ const allPostsByDate = sortMDByDate(allPosts).slice(0, MAX_POSTS)
105104
</Section>
106105
</div>
107106
</section>
108-
<script is:inline>
109-
// Force light theme on homepage
110-
localStorage.setItem('theme', 'light')
111-
document.documentElement.dataset.theme = 'light'
112-
113-
// Set body background color
114-
document.body.style.backgroundColor = '#fffaf6'
115-
116-
// Prevent horizontal scrollbar caused by 100vw elements
117-
document.body.style.overflowX = 'hidden'
118-
</script>
107+
<script is:inline>
108+
// Force light theme on homepage
109+
localStorage.setItem('theme', 'light');
110+
document.documentElement.dataset.theme = 'light';
111+
// Add class to body for homepage-specific styles
112+
document.body.classList.add('hide-scrollbar');
113+
</script>
119114
</main>
120115

121116
<script>

0 commit comments

Comments
 (0)