Make a simple html+css page that scrolls like the Star Wars opening crawl using…
- User
Make a simple html+css page that scrolls like the Star Wars opening crawl using perspective, transforms etc.
- Assistant
Below is a simple HTML and CSS page that recreates the Star Wars opening crawl effect. It uses CSS properties like
perspective,transform, and animations to achieve the scrolling text illusion. The text starts from the middle of the screen and scrolls upwards into the distance, mimicking the classic Star Wars style.Explanation of the Code:
- HTML Structure: A container div (
crawl) holds the title and content. This allows us to apply transformations to the entire block. - CSS Key Features:
perspectiveon the body creates a 3D space.transform: rotateX(30deg)tilts the text upwards for the angled effect.@keyframesanimation moves the text upwards (viatranslateY) and into the distance (viatranslateZ).- The animation is set to run linearly for 60 seconds (you can adjust this duration).
- Basic styling: Black background, yellow text, and centered alignment for a Star Wars-like feel.
Save the HTML in a file (e.g.,
index.html) and the CSS in a separate file (e.g.,styles.css), then open the HTML file in a web browser to see the effect.index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Star Wars Opening Crawl</title> <link rel="stylesheet" href="styles.css"> </head> <body> <div class="crawl"> <div class="title">A long time ago in a galaxy far, far away...</div> <div class="content"> <p>EPISODE I</p> <p>THE PHANTOM MENACE</p> <p>TEXT HERE. It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire.</p> <p>During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station with enough power to destroy an entire planet.</p> <p>Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy....</p> </div> </div> </body> </html>styles.css
body { margin: 0; padding: 0; background-color: black; /* Black background like Star Wars */ color: yellow; /* Yellow text color */ font-family: sans-serif; /* Simple font for readability */ display: flex; justify-content: center; align-items: center; /* Center the crawl container */ height: 100vh; /* Full viewport height */ overflow: hidden; /* Hide any overflow to prevent scrollbars */ perspective: 1000px; /* Create 3D perspective for depth */ } .crawl { transform-style: preserve-3d; /* Preserve 3D transformations for child elements */ transform: rotateX(30deg); /* Tilt the text upwards for the crawl effect */ animation: scroll 60s linear infinite; /* Animate for 60 seconds, linearly, and loop */ text-align: center; /* Center the text */ font-size: 2em; /* Base font size for the content */ width: 80%; /* Make it responsive but not too wide */ } .title { font-size: 1.5em; /* Larger font for the title */ margin-bottom: 2em; /* Space between title and content */ } .content { line-height: 1.5; /* Spacing between lines for readability */ } @keyframes scroll { 0% { transform: rotateX(30deg) translateY(0) translateZ(0); /* Start at the middle */ } 100% { transform: rotateX(30deg) translateY(-2000px) translateZ(-2000px); /* Move upwards and into the distance */ } }How to Use:
- Create two files:
index.htmlandstyles.css. - Place them in the same directory.
- Open
index.htmlin a web browser. - The text will start scrolling automatically. You can adjust the animation duration in the
@keyframesrule (e.g., change60sto30sfor faster scrolling).
This is a basic implementation. If you'd like to add more features (e.g., fading, sound, or responsiveness), let me know!
- HTML Structure: A container div (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.