I know that marquee is obsolete but I have an emergency
in-memoriam video to produce with no time for learning
anything else except the type of code below which does
NOT scroll the page all the way. It stops when the first
line hits the top of the browser. Any way to make it
scroll until the bottom line has scrolled up to just
above the window bottom frame? TIA
On Fri, 24 Jan 2025 19:57:40 -0500, bad sector wrote:
I know that marquee is obsolete but I have an emergency
in-memoriam video to produce with no time for learning
anything else except the type of code below which does
NOT scroll the page all the way. It stops when the first
line hits the top of the browser. Any way to make it
scroll until the bottom line has scrolled up to just
above the window bottom frame? TIA
Use CSS. Search for: CSS based marquee
JJ wrote:
On Fri, 24 Jan 2025 19:57:40 -0500, bad sector wrote:
I know that marquee is obsolete but I have an emergency
in-memoriam video to produce with no time for learning
anything else except the type of code below which does
NOT scroll the page all the way. It stops when the first
line hits the top of the browser. Any way to make it
scroll until the bottom line has scrolled up to just
above the window bottom frame?-a TIA
Use CSS. Search for: CSS based marquee
I wrote the OPrCOs question almost verbatim to ChatGPT, just adding the of using CSS (which ChatGPT probably would have figured out itself), and I
got this:
You can use CSS and JavaScript to simulate the behavior of the <marquee> element. Below is an example of how you can create a scrolling effect
with CSS and JavaScript that behaves as you describedrCoscrolling the text until the last line moves out of view.
HTML + CSS + JavaScript Code
html
<!DOCTYPE html>
<html lang="en">
<head>
-a <meta charset="UTF-8">
-a <meta name="viewport" content="width=device-width, initial-scale=1.0">
-a <title>In-Memoriam Scroll</title>
-a <style>
-a-a-a body {
-a-a-a-a-a background-color: #006600;
-a-a-a-a-a color: white;
-a-a-a-a-a margin: 0;
-a-a-a-a-a overflow: hidden;
-a-a-a-a-a font-family: Arial, sans-serif;
-a-a-a-a-a display: flex;
-a-a-a-a-a align-items: center;
-a-a-a-a-a justify-content: center;
-a-a-a-a-a height: 100vh;
-a-a-a }
-a-a-a .scroll-container {
-a-a-a-a-a position: relative;
-a-a-a-a-a width: 100%;
-a-a-a-a-a height: 100%;
-a-a-a-a-a overflow: hidden;
-a-a-a }
-a-a-a .scroll-text {
-a-a-a-a-a position: absolute;
-a-a-a-a-a top: 100%; /* Start just outside the visible area */
-a-a-a-a-a width: 100%;
-a-a-a-a-a text-align: center;
-a-a-a-a-a font-size: 2rem; /* Adjust font size */
-a-a-a-a-a line-height: 1.5;
-a-a-a }
-a </style>
</head>
<body>
-a <div class="scroll-container">
-a-a-a <div class="scroll-text" id="scroll-text">
-a-a-a-a-a <p>In loving memory of John Doe</p>
-a-a-a-a-a <p>Forever in our hearts</p>
-a-a-a-a-a <p>March 3, 1950 - December 12, 2024</p>
-a-a-a-a-a <p>You will never be forgotten.</p>
-a-a-a </div>
-a </div>
-a <script>
-a-a-a const scrollText = document.getElementById('scroll-text');
-a-a-a const container = document.querySelector('.scroll-container');
-a-a-a // Calculate the animation duration dynamically based on text height
-a-a-a const textHeight = scrollText.offsetHeight;
-a-a-a const containerHeight = container.offsetHeight;
-a-a-a const scrollDuration = (textHeight + containerHeight) * 10; // Adjust speed by multiplying
-a-a-a // Apply the animation
-a-a-a scrollText.style.animation = `scrollUp ${scrollDuration}ms linear`;
-a-a-a // Add CSS animation via JavaScript
-a-a-a const style = document.createElement('style');
-a-a-a style.textContent = `
-a-a-a-a-a @keyframes scrollUp {
-a-a-a-a-a-a-a 0% {
-a-a-a-a-a-a-a-a-a top: 100%;
-a-a-a-a-a-a-a }
-a-a-a-a-a-a-a 100% {
-a-a-a-a-a-a-a-a-a top: -${textHeight}px;
-a-a-a-a-a-a-a }
-a-a-a-a-a }
-a-a-a `;
-a-a-a document.head.appendChild(style);
-a </script>
</body>
</html>
Explanation:
CSS Structure:
.scroll-container: Defines the visible area where the text scrolls. .scroll-text: The text that scrolls upwards.
JavaScript:
Dynamically calculates the total height of the scrolling text and the container to determine how long the scrolling animation should last.
Uses @keyframes to define the animation that moves the text from the
bottom to above the visible area.
Customization:
Modify font-size, line-height, or the speed calculation (* 10) in scrollDuration to suit your preferences.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 08:14:18 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
2 files (6,679K bytes) |
| Messages: | 264,942 |