This zone is sleeping right now! ZzzZZzzz

Better not disturb it! ~You go to the petrol station and buy a slushy instead, everything is cool!~

This area will open again in 000.beats!

(Learn about Swatch Time)

Some other zones are awake :^]


Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
Autumn, 19 Oct 2026 - @920.39
Forum Activity: Two Stars Random | Recent Posts | Guild Recents
News: :seal: Thank you for today! :seal: Guild Events: MelonLand's Seasonal RPG Jam
Super News: ~~MelonLand's Halloween Profile Design Contest 2026~~
+  MelonLand Forum
|-+  Da Web Revival
| |-+  ✁ ∙ Web Crafting
| | |-+  ♺ ∙ Snippets & Materials
| | | |-+  How to make a marquee that pauses when you hover it


« previous next »
Pages: [1] Print Embed
Author Topic: How to make a marquee that pauses when you hover it  (Read 651 times)
Noah_S
Sr. Member ⚓︎
****
View Profile WWWArt


Noah. Earth. I make website. I.. I.. Noah. Earth.
⛺︎ My Room
iMood: Noah_S
RSS: RSS

Guild Memberships:
Artifacts:
Caught by RubbereonfunguyVisited on Melon's 10th Anniversary!I got robbed by Dan Q on Melonland!I met Dan Q on Melonland!A coin!
« on: Summer, 25 Jul 2026 @426 » Toggle Font Embed

I was reading the websites pet peeves thread, and saw some discussion about marquees. So here's a code for making them pause when you hover over them.

Code
<style>
.scroll-text {
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  animation: scroll-left 15s linear infinite;
  &:hover {
  animation-play-state: paused;
}
}

@keyframes scroll-left {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(-100%);
  }
}
</style>

<div class="scroll-text">This scrolls left using CSS</div>

I tested it in the w3schools tryit editor to check, and it works.

Code
  animation: scroll-left 15s linear infinite;

This affects how fast it's moving. Lower numbers make faster movement.

I don't fully understand the code myself, I haven't played with animations and this is a frankencode from different sources that I jigsawed until I found a combination that worked. But one of the sources said that this wouldn't confuse screenreaders, which <marquee> does, and I hope that that's accurate.

Logged

perfectionist_better.gifweb_designer.gifspeed_of_time.gifbutton290.pngmy_dream_wedding.gifClippy beats AI

Artifact Swap: Large watercraftGrowing ballwhen life gives you crab make mailMessage BuddylaptopYarn kitty
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
Artifacts:
The Worm is creeping around Melonland profiles!Dan Q Cruisin'I DIDN'T meet Dan Q on Melonland!Visited on Melon's 10th Anniversary!
« Reply #1 on: Summer, 25 Jul 2026 @724 » Toggle Font Embed

I don't fully understand the code myself, I haven't played with animations and this is a frankencode from different sources that I jigsawed until I found a combination that worked.

Let me see if I can help with the comprehension! I've added some comments and tweaked the indentation.

Code
<style>
/* Anything with <... class="scroll-text">: */
.scroll-text {
  /* 1. Is as wide as whatever contains it: */
  width: 100%;
  /* 2. Anything that doesn't fit within it gets hidden: */
  overflow: hidden;
  /* 3. And text isn't allowed to wrap within it (therefore anything that "goes off the side" is hidden!): */
  white-space: nowrap;
  /* 4. Also, it gets an animation called "scroll-left", which
   *    takes 15 seconds to run (15s)
   *    at the same speed for the entire process (linear)
   *    repeating forever (infinite)
   */
  animation: scroll-left 15s linear infinite;

  /* When the cursor hovers over that <... class="scroll-text">... */
  &:hover {
    /* ...the animation is paused. */
    animation-play-state: paused;
  }
}

/* This bit defines the animation called "scroll-left": */
@keyframes scroll-left {
  /* 1. The animation STARTS with... */
  from {
    /* ...the position of the contents moved 100% of its width, to the right (X), i.e. entirely "off" the right. */
    transform: translateX(100%);
  }
  /* 2. The animation ENDS with... */
  to {
    /* ...the position of the contents moved 100% of its width, to the left (minus X), i.e. entirely "off" the left. */
    transform: translateX(-100%);
  }
}
</style>

<!--
  here's an element that scrolls, because it has class="scroll-text"
  so everything above applies. It doesn't have to be a <div>; indeed
  a <p>, <h2> or <li> might be more-applicable depending on the
  circumstances!
-->
<div class="scroll-text">This scrolls left using CSS</div>

With all of that new knowledge, we now have everything we need to e.g.

- make the animation faster or slower (by changing "15s" to some other duration)
- make the marquee "bounce" backwards and forwards by adding animation-direction: alternate;
- delay the start of the marquee with animation-delay: 2s; (2 second delay), OR have it start "as if" it had been playing a while already with a negative value like animation-delay: -2s; (normal loop, but when the page loads it's like it started two seconds ago
- swap the "linear" to make it gradually speed up at the start (ease-in), gradually slow down at the end (ease-out), or both (ease-in-out) - these look a little odd for text marquees, but are useful in some other animations
- make it run "backwards" with animation-direction: reverse; (or by swapping the from { ... } and to { ... } section contents

Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif https://origami.danq.dev/88x31.gif

Artifact Swap: PolyamorousI met Dan Q on Melonland!Joined 2025!
Noah_S
Sr. Member ⚓︎
****
View Profile WWWArt


Noah. Earth. I make website. I.. I.. Noah. Earth.
⛺︎ My Room
iMood: Noah_S
RSS: RSS

Guild Memberships:
Artifacts:
Caught by RubbereonfunguyVisited on Melon's 10th Anniversary!I got robbed by Dan Q on Melonland!I met Dan Q on Melonland!A coin!
« Reply #2 on: Summer, 25 Jul 2026 @771 » Toggle Font Embed

Thank you. I think you cracked animations for me. I've been fascinated by that dragonfly in the garden.

Logged

perfectionist_better.gifweb_designer.gifspeed_of_time.gifbutton290.pngmy_dream_wedding.gifClippy beats AI

Artifact Swap: Large watercraftGrowing ballwhen life gives you crab make mailMessage BuddylaptopYarn kitty
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
@000 Melon
Land
Forum Art Hub Chat Webring Explore Random Recent Tenement Arcade Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Help I'm Lost! Link Land Newsletters Image Stream Minecraft: Online
Zap!
Passport Sites tamaNOTchi Asatte Add your site?
Aero Archive Onio Cafe 32 Bit Cafe Status Cafe