How to Create Text Scrolling Animation with Css Code

Author

Reads 513

Man Holding and Scrolling a Black Smartphone
Credit: pexels.com, Man Holding and Scrolling a Black Smartphone

Creating a text scrolling animation with CSS can be a fun and rewarding project, and it's actually quite straightforward once you know the basics. To get started, you'll need to understand the concept of animation and how it works in CSS.

Animation in CSS is achieved using the `@keyframes` rule, which defines the animation sequence. You can use this rule to create a scrolling effect by moving the text up or down the page. For example, as shown in the article section, you can use the following code: `@keyframes scroll { from { transform: translateY(0); } to { transform: translateY(-100%); } }`.

To apply the animation, you'll need to add the `animation` property to your text element. You can specify the animation name, duration, and timing function to control the animation. For instance, you can use the following code to apply the animation: `text { animation: scroll 10s linear infinite; }`.

The key to creating a smooth scrolling effect is to set the animation duration and timing function carefully. As demonstrated in the article section, a duration of 10 seconds and a linear timing function can create a smooth and continuous scrolling effect.

Worth a look: Scrolling Text Html

Creating a Text Scrolling Animation

Credit: youtube.com, CSS Animation - Text scrolling effect |#SkillUpwithGenie

Creating a text scrolling animation is a great way to add some visual interest to your website. To create our scrolling text, we'll use CSS animations paired with the transform: translateX and transform: translateY properties.

You can use the translateY() function to make the text scroll up or down, and switch the values around to achieve the opposite effect. For example, to make the text scroll down, you would use translateY(100%) instead of translateY(-100%).

Here are some key CSS properties to keep in mind when creating a text scrolling animation:

To ensure cross-browser compatibility, don't forget to add animation rules with vendor prefixes like -webkit- and -moz-. This will help your animation work seamlessly in Safari, Chrome, and Firefox.

How To Create

To create a text scrolling animation, you'll use CSS animations paired with the transform: translateX and transform: translateY properties. This combination will allow you to move your text across the screen.

See what others are reading: Text Transform Css

Credit: youtube.com, Create a SCROLLING TEXT In OBS Studio in 3 minutes

To ensure cross-browser compatibility, you'll need to add animation rules with vendor prefixes like -webkit- for Safari and Chrome, and -moz- for Firefox. This will make your animation work seamlessly across different browsers.

Start by creating right-to-left text, which is a crucial step in making your animation work. This will give you a solid foundation to build upon.

Custom animations employing CSS properties like opacity and transform can be used to manipulate the content's visibility and movement based on scroll position. This creates a dynamic and visually appealing effect.

Examples

Creating a text scrolling animation can be a great way to add some visual interest to your website. Scrolling text can dominate a homepage, like in the example of a hot sauce brand, where the text moves left-to-right, right-to-left, and vertically across the page as you scroll down.

This type of animation can grab the visitor's attention and add a bit of playfulness to a website's design, making it more engaging for users.

Check this out: Css to Add Text

Left to Right

Credit: youtube.com, Continuous Scrolling Text Effect in PowerPoint 2013

Creating a text scrolling animation can be a fun and creative way to add some visual interest to your website.

To scroll text from left to right, you can simply switch the values of translateX() around so that 100% becomes -100% and vice-versa. This is exactly what we see in the example code for "Left to Right" in the article.

The starting position is also set to -100% in this example, and the class and animation names are changed to scroll-right. This is a great way to keep your code organized and easy to read.

Here's a summary of the key changes you'll need to make to scroll text from left to right:

By making these simple changes, you can create a scrolling text animation that moves from left to right across the page.

Human-Centered Landing Page

To create a human-centered landing page, you can use CSS animations paired with the transform: translateX and transform: translateY properties, as seen in the example of scrolling text. This technique ensures cross-browser compatibility by adding animation rules with vendor prefixes.

Credit: youtube.com, How to Create Full Page Website Scroll Animation in Figma | Figma Tutorial

The animation-range property can be used to define the portion of the viewport where the animation should occur, like in the animated scrolling introduction example. This feature allows you to trigger the animation between specific percentages of the viewport height.

For a more dynamic and engaging user experience, you can use scroll-driven animations triggered based on scroll position, as demonstrated in the humane-inspired CSS scroll-driven animation landing page example. This approach creates a seamless transition between different sections of the page.

To make the text scroll down, you can use the translateY() function, switching the values around, as shown in the scroll down example. This technique involves setting the starting position to -100% and animating it to 100% over a specified duration.

Here are some key animation properties to keep in mind:

By incorporating these techniques and properties into your design, you can create a human-centered landing page with a text scrolling animation that captures the user's attention and provides an engaging user experience.

Types of Text Scrolling Animations

Credit: youtube.com, Build an Scroll Animation Text Effect Using Only CSS

Text scrolling animations can be categorized into three main types: vertical scrolling, horizontal scrolling, and diagonal scrolling.

Vertical scrolling is a common technique that involves scrolling text from top to bottom or bottom to top. This type of animation is often used in websites with a lot of content, such as news websites or blogs.

Horizontal scrolling is another type of animation that involves scrolling text from left to right or right to left. This type of animation is often used in websites with a modern or minimalist design.

Diagonal scrolling is a less common technique that involves scrolling text at an angle. This type of animation can be used to add visual interest to a website or to draw attention to a specific piece of content.

In CSS, vertical scrolling can be achieved using the overflow property, while horizontal scrolling can be achieved using the overflow-x property.

Worth a look: Css Scrolling Text

CSS Techniques

You can create a left-to-right scrolling text by swapping the positive and negative translateX values in your CSS. Simply change all instances of 100% to -100% and all instances of -100% to 100%.

Credit: youtube.com, Build an Infinite Scroll Animation Effect Using Only CSS

To right-align the text inside the scrolling container, you can add a style to the container, like scroll-text in the example.

For a more visually appealing effect, you can use sticky positioning to keep the scrolling text in place as the user scrolls through the page. This can be achieved by using 90% of the sticky positioning feature.

Curious to learn more? Check out: Html Scrolling Text Box

About The Code

In this article, we'll take a closer look at the code behind some of the CSS techniques we'll be exploring. About The Code, let's start with the basics.

The code for simple scroll animations is written in HTML, CSS, and JavaScript. This combination is a common one in web development.

To give you a better idea of what's involved, here are the specific technologies used for the example code:

  • HTML (Pug)
  • CSS (SCSS)
  • JavaScript (Babel)

These technologies work together to create a smooth and engaging user experience.

Pure Continuous Horizontal

Creating a continuous horizontal scrolling effect in CSS can be a bit tricky, but it's definitely doable. To achieve this, you can use the translateX property, as shown in Example 1, where the author swaps the positive and negative translateX values to create a left-to-right scrolling effect.

Credit: youtube.com, Infinite Scrolling Animation | CSS Only Text and Image Carousel

To avoid a break between loops, try using a pure CSS/html solution, like the one attempted in Example 2. Unfortunately, even with the author's rudimentary attempt, an unwanted break between each loop still occurs.

If you're looking for a simple horizontal scrolling animation, take a look at Example 3, where the author creates a marquee effect reminiscent of the "good old days".

For another approach, see: Webp Example

Up

You can get 90% with sticky positioning. It's a great way to keep elements in place as the user scrolls.

Sticky positioning is particularly useful for scroll-driven elements. For extra visual flair, you can wrap these elements in @supports.

Progressive enhancement is a key concept here. It means adding extra features for users who can handle them, without breaking the experience for those who can't.

Customization and Effects

CSS scroll-driven animations offer a high degree of customization, allowing you to fine-tune the animation to your liking.

The animation-range property is where you have the most control over each animation, and it's where the author spent the most time figuring it out.

The author mentions that Bramus made an excellent tool to visualize the animation-range, which is a big help in getting it right.

Here are some possible variations for animation-range, but keep in mind that there are many more possibilities:

Speed

Crop unrecognizable male browsing modern netbook and scrolling touchpad placed on stand on desk
Credit: pexels.com, Crop unrecognizable male browsing modern netbook and scrolling touchpad placed on stand on desk

Speed is a crucial aspect of creating a smooth and engaging scrolling effect. You can control the speed of the animation by adjusting the value in the animation property.

To slow down the animation, you can use a higher number in the animation property, such as 25s. This means it will take 25 seconds for the animation to complete.

A higher number slows down the marquee, while a lower number speeds it up. For example, using 15s will speed up the animation compared to using 25s.

Here's a simple way to think about it: the lower the number, the faster the animation will be, and the higher the number, the slower it will be.

Additional reading: Web Phone Number Free

Background and Effect

Customization and Effects are key to making your website stand out. A "Background and Text Scroll Effect" can be achieved with a super quick idea for a text reveal effect on scroll.

This effect can be created with a simple code snippet or a pre-made plugin. You can also use a pre-made plugin to add a "Background and Text Scroll Effect" to your website.

See what others are reading: Webflow Scroll Animations

ESIM Text on Smartphone Screen
Credit: pexels.com, ESIM Text on Smartphone Screen

The "Background and Text Scroll Effect" can be customized with different colors, fonts, and animations to match your website's style. You can also adjust the speed and timing of the effect to fit your needs.

A "Background and Text Scroll Effect" can add a professional touch to your website and make it more engaging for your visitors. It's a great way to draw attention to important content or calls-to-action.

Hidden

Hidden effects can add a new level of engagement to your website or application. Not just vertically scrolling, but also hidden text can be used to create a unique user experience.

You can see an example of hidden and scrolling text in action with a simple hover effect. Hover over the window to check out this effect.

This effect is achieved with a combination of CSS and JavaScript, allowing for a seamless and interactive experience.

Intriguing read: Hover Text Css

Write-On Effect

The Write-On Effect is a type of animation that reveals text as you scroll down a webpage. It's a new feature in CSS that's still in its early days, but it's already making a big impact.

Credit: youtube.com, Write-On Text Animation in After Effects CC 2020

CSS scroll-driven animations are a game-changer, allowing you to create effects like this with zero JavaScript. This demo is a great example of how to create a write-on text effect using CSS scroll-driven animations.

Here are the basic steps to create a write-on effect:

  1. Declare a @keyframes animation named write that increases the width of a clip-path from 0 to 100%.
  2. Apply the write animation to each p element.
  3. Give the timeline a unique name, --written-text, and set that as the animation-timeline.
  4. Using animation-range, refine how the animation progresses related to the scroll position of each p element.

The animation-range is where you have the most control over each animation, and it's where the author of the demo spent the most time figuring it out.

Specific Animation Styles

Animated scrolling introductions can be achieved with CSS, where the animation is applied to the second section's heading. The animation-range feature is set to trigger between 0% and 50% of the viewport height.

The revealing animation keyframes control the transition, starting with the heading off-screen, gray, blurred, and reduced opacity. It then slides into view, sharpens focus, and becomes fully visible.

Feature animation-range and revealing animation keyframes work together to create a smooth scrolling effect.

Vertical

Vertical animations can be achieved through CSS properties like translateY. To make text scroll vertically from bottom to top, change all occurrences of translateX to translateY in your code.

From below of cheerful elegant African American female texting message on cellphone while standing on stairs with railings on street
Credit: pexels.com, From below of cheerful elegant African American female texting message on cellphone while standing on stairs with railings on street

You can center the text and decrease the animation duration to 5 seconds for a more apparent vertical scroll. A height value for the div container also helps make the vertical scroll more noticeable.

To change the direction of the vertical scroll, simply flip the positive and negative translateY values. This can create a top-to-bottom scrolling effect.

A clean and smooth animation can be created by replacing a word in a line of text with a vertical scrolling word. This style can be achieved through a combination of previous examples.

For a more complex animation, you can use a combination of transforms and vmin units to create a diagonal scroll effect. This can add a unique touch to your animations.

Content Reveal

Content Reveal is a fantastic way to draw attention to your content as users scroll down the page. The magic lies in the animation applied to the second section's heading, which smoothly reveals itself with a cool animation.

Readers also liked: Content Protection Network

Credit: youtube.com, Creating Engaging Animated Content with Hiding and Revealing Techniques on a Single HTML Page

The animation-range feature defines the portion of the viewport where the animation should occur, in this case, between 0% and 50% of the viewport height. This allows the animation to trigger at the right moment.

Use the clip-path property to create fixed position hero sections, which can be especially effective for revealing content on scroll. I've seen this technique used to great effect in modern web design.

Custom animations employing CSS properties like opacity and transform manipulate the content's visibility and movement based on scroll position. This creates a dynamic and visually appealing effect.

The @keyframes property is used to control the transition of the animation, allowing you to specify the exact timing and movement of the content. This is a powerful tool for creating complex animations.

Content Reveal animations can also be used to create a sense of movement and energy on the page. By using CSS features like custom properties and grid layout, you can create complex animations that engage the user.

The key to creating a great Content Reveal animation is to use it to draw attention to the content that matters most. By using the animation to highlight key points or calls to action, you can create a more engaging and effective user experience.

Here's an interesting read: Which Web Browser Is Most Used Worldwide

Like Indicator

Person holding smartphone with green screen for display mockup.
Credit: pexels.com, Person holding smartphone with green screen for display mockup.

The Like Indicator is a clever animation that can be achieved with just a few lines of CSS. This trick uses a CSS scroll-driven animation to create a scroll-driven effect.

To create the Like Indicator, you can use a CSS animation that's triggered by the page scroll. This is exactly what's described in the Scroll to Like Indicator With CSS Scroll-Driven Animation example.

Using a pseudo-element on the like button is a great way to create this effect. You can translate the pseudo-element at the end of the article to achieve the desired animation.

Broaden your view: Webflow Text Scroll

Other Animation Techniques

You can also use CSS animation-timeline to create a synchronized scrolling animation across sections. This technique is particularly useful for creating a dynamic and visually appealing effect.

Custom animations can be created using CSS properties like opacity and transform to manipulate the content's visibility and movement based on scroll position.

Cory Hayashi

Writer

Cory Hayashi is a writer with a passion for technology and innovation. He started his career as a software developer and quickly became interested in the intersection of tech and society. His writing explores how emerging technologies impact our lives, from the way we work to the way we communicate.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.