Skip to content

Commit bb1f7c5

Browse files
committed
Marquee to CSS fix
1 parent 00990b3 commit bb1f7c5

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

src/pages/index.astro

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,20 @@ const paddedStamps = Array(copies).fill(stamps).flat();
2727
</div>
2828

2929
<div class="box subheader">
30-
<marquee behavior="scroll" direction="right" style="color:rgb(3, 48, 252); text-shadow: 0 0 6px #ffffff, 0 0 10px #ffffff; font-weight: bold; font-size: 14px;">
31-
Welcome to my site!
32-
</marquee>
30+
<div class="welcome-scroll">
31+
<span>Welcome to my site!</span>
32+
</div>
3333
</div>
3434
<div class="box subheader stamps">
3535
<div class="marquee" aria-label="Stamp collection">
3636
<div class="marquee__inner">
37-
{paddedStamps.map(src => <img src={src} alt="" decoding="async" fetchpriority="low" />)}
37+
{paddedStamps.map(src => <img src={src} alt="" fetchpriority="low" />)}
3838
</div>
3939
<div class="marquee__inner" aria-hidden="true">
40-
{paddedStamps.map(src => <img src={src} alt="" decoding="async" fetchpriority="low" />)}
40+
{paddedStamps.map(src => <img src={src} alt="" fetchpriority="low" />)}
4141
</div>
4242
</div>
4343
<script>
44-
// Pause the marquee until all stamp images have loaded, then fade in.
45-
// This prevents the janky partial-load stutter.
4644
const marquee = document.querySelector('.marquee') as HTMLElement;
4745
if (marquee) {
4846
const imgs = marquee.querySelectorAll('img');
@@ -91,6 +89,29 @@ const paddedStamps = Array(copies).fill(stamps).flat();
9189
background: linear-gradient(to bottom, #BDD3F4 0%, #92AEED 50%, #597997 51%, #A8BEFF 100%);
9290
}
9391

92+
.welcome-scroll {
93+
display: flex;
94+
overflow: hidden;
95+
height: 100%;
96+
align-items: center;
97+
}
98+
99+
.welcome-scroll span {
100+
display: inline-block;
101+
white-space: nowrap;
102+
padding-left: 100%;
103+
animation: welcome-scroll 12s linear infinite;
104+
color: rgb(3, 48, 252);
105+
text-shadow: 0 0 6px #ffffff, 0 0 10px #ffffff;
106+
font-weight: bold;
107+
font-size: 14px;
108+
}
109+
110+
@keyframes welcome-scroll {
111+
from { transform: translateX(-100%); }
112+
to { transform: translateX(100%); }
113+
}
114+
94115
/* Stamp marquee bar */
95116
.stamps {
96117
height: 60px;
@@ -117,7 +138,6 @@ const paddedStamps = Array(copies).fill(stamps).flat();
117138
transition: opacity 0.3s ease;
118139
}
119140

120-
/* Stamps start hidden+paused, then fade in once all images load */
121141
.marquee.is-ready .marquee__inner {
122142
animation-play-state: running;
123143
opacity: 1;
@@ -138,6 +158,9 @@ const paddedStamps = Array(copies).fill(stamps).flat();
138158
animation-play-state: paused !important;
139159
opacity: 1 !important;
140160
}
161+
.welcome-scroll span {
162+
animation-play-state: paused !important;
163+
}
141164
}
142165

143166
/* ── Mobile overrides ─────────────────────────────────────────────────────
@@ -146,11 +169,9 @@ const paddedStamps = Array(copies).fill(stamps).flat();
146169
them along with everything else.
147170

148171
Logo: left: -90px sits at -255px in layout coords (header is at -165px).
149-
Setting left: 165px cancels the header's -165px, landing the logo right
150-
at the layout's left edge (~10px from viewport at 375px / scale 0.37).
172+
Setting left: 110px brings the logo onto screen after scaling.
151173

152174
Heights doubled so they appear the same relative size after scaling.
153-
Font-size doubled; needs !important to beat the inline style.
154175
───────────────────────────────────────────────────────────────────────── */
155176
@media (max-width: 1020px) {
156177
.logo-wrap {
@@ -173,9 +194,8 @@ const paddedStamps = Array(copies).fill(stamps).flat();
173194
height: 104px;
174195
}
175196

176-
.subheader:not(.stamps) marquee {
177-
font-size: 28px !important;
178-
line-height: 60px;
197+
.welcome-scroll span {
198+
font-size: 28px;
179199
}
180200
}
181201
</style>

0 commit comments

Comments
 (0)