Creating visual effects with text in HTML

Looking to add animation to two paragraphs with text in them? Want the first paragraph to move from left on the x-axis, and the second paragraph from right to left?

If your code is only working for one direction (left or right), here's a possible solution:

<!DOCTYPE html>
<html>
<head>
<style> 

#text {
         position:relative;
         -webkit-animation: mymove infinite; /* Chrome, Safari, Opera */
         -webkit-animation-duration: 2s; /* Chrome, Safari, Opera */
         animation: mymove infinite;
         animation-duration: 2s;
      }

/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
         from {top: 200px;}
         to {top: 0px;}
      }

@keyframes mymove {
         from {top: 0px;}
         to {top: 100px;}
      }

#text1 {
         position:relative;
         -webkit-animation: mymove1 infinite; /* Chrome, Safari, Opera */
         -webkit-animation-duration: 2s; /* Chrome, Safari, Opera */
         animation: mymove1 infinite;
         animation-duration: 2s;
       }

/* Chrome, Safari, Opera */
@-webkit-keyframes mymove1 {
         from {right: -200px;}
         to {right: 0px;}
       }

@keyframes mymove1 {
         from {top: 0px;}
         to {top: 100px;}
       }
       
</style>
</head>
<body>
      <p id="text">Some text goes here</p>
      <p id="text1">text display animation</p>
</body>
</html>

This should animate the second paragraph from right to left and the first one from left to right. Try it out and see if it works!

Answer №1

VIEW DEMO

#content {
         position:relative;
         -webkit-animation: moveText infinite; /* Chrome, Safari, Opera */
         -webkit-animation-duration: 3s; /* Chrome, Safari, Opera */
         animation: moveText infinite;
         animation-duration: 3s;
      }

/* Chrome, Safari, Opera */
@-webkit-keyframes moveText {
         from {top: 100px;}
         to {top: 0px;}
      }

@keyframes moveText {
         from {top: 100px;}
         to {top: 0px;}
      }

#content2 {
         position:relative;
         -webkit-animation: moveText2 infinite; /* Chrome, Safari, Opera */
         -webkit-animation-duration: 3s; /Chrome, Safari, Opera/
         animation: moveText2 infinite;
         animation-duration: 3s;
       }

/* Chrome, Safari, Opera */
@-webkit-keyframes moveText2 {
         from {bottom: 200px;}
         to {bottom: 0px;}
       }

@keyframes moveText2 {
         from {bottom: 200px;}
         to {bottom: 0px}
       }

Answer №2

How to implement #text in CSS:

-webkit-animation-direction: reverse; /* Compatible with Chrome, Safari, Opera */
animation-direction: reverse;

Click here for an example implementation!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

`Position the login page contents in the center`

Having some difficulty centering the content on my login page. Can you assist with styling? I would like to have the input fields centralized and compact, similar to a standard login page. Also, I am encountering an issue with using different Bootstrap ver ...

Is it possible to direct the user to a particular link upon swiping to unlock?

Hello everyone, I could use some assistance with this code. I am looking to redirect someone to a specific page when they swipe to unlock and automatically transfer them to another page when the swipe ends. Any help is greatly appreciated. Thank you! $ ...

Attempting to connect with an Elementor Form submission

I am currently working on a functionality to toggle the visibility of a download button once a user has submitted their email through a standard Elementor form. Despite Elementor offering various actions, I have found that I can only achieve this toggle us ...

css: maximum width or maximum size

My website features images with a width of 720 pixels. I am looking for a way to ensure that these images are either 95% of the page's width (with a maximum width set at 95%), or 720px if the screen size is too large. This is to prevent distortion on ...

I attempted to shift the pseudo element to the left by using a negative margin-left value when the parent element is active, however, the desired effect was not achieved

<!-- how do I troubleshoot this issue? --> <!-- languages used: HTML and CSS--> <!DOCTYPE html> <html> <head> <style> This section styles the button and gives it a relative position. .button { ...

Is there a way to change HTML retrieved from an AJAX request before inserting it into the document?

I am utilizing an ajax call to retrieve an HTML page from the server; the ajax call is structured as follows: function loadHtml() { $.ajax({ type : 'GET', async : false, url : &apos ...

What is the best way to adjust the background-position of CSS specifically for the X axis?

My goal is to create a CSS animation that changes the background-position of a div, similar to the following: @keyframes wave{ from{ background-position: 80% center; } to{ background-position: 160% center; } } While this a ...

Angular and Bootstrap do not support margin styles

While working with Angular 5 and Bootstrap, I have encountered an issue with using inline styles for margin. The template I am using is as follows: @Component({ selector: "dynamic-container-component", template: ` <div styl ...

Styling JavaScript strings with CSS - JavaScript/CSS Integration

I am trying to display a tooltip on hover using the data-tip attribute, but I am facing limitations with it only accepting strings. As a workaround, I have adopted the following approach: var title = "Hello World"; var online: "Last Online 2 mins ago". ...

What could be causing this Bootstrap 4 code to only show one image per row on smaller screens?

On a large screen, it displays three images which is ideal, but on a small window it only shows one image per row when it should be displaying 2 images instead. <div class="container"> <h2>Pictures of Coffee</h2> <div class="row" ...

What is the best way to position an image within a smaller div at the center?

Similar Question: Aligning image to center inside a smaller div I am facing an issue related to CSS 3. Here is a snippet of my HTML code: <div id="main" style="width: 320px; height: 400px;"> <img src="test.jpg" height="400" /> </div ...

Tips for connecting a suspended div below a Bootstrap 5 fixed navigation bar

I successfully implemented a sticky navigation using Bootstrap 5, and now I want to add a hanging div (.chat-tag) below the sticky nav for a chat feature. This "hanging tag" should stay attached to the sticky nav as the user scrolls down the page. It&apos ...

How to position a div in the center of the screen with an overlay

While this code functions well in Firefox, it unfortunately does not work in IE. I am seeking a solution to properly center the div on the screen - Currently, the div is leaning too much towards the bottom In addition, I require the div with an id of "l ...

A guide on extracting text enclosed by <a> and </a> tags using regular expressions

I have come across the following code: <a align="center" href="http://google.com"><b>Google Link<b></b></a> <a align="center" href="http://yahoo.com"><strong>Yahoo Link</strong></a> Now, I am looking ...

Ensure that the images maintain a horizontal flow while keeping any overflow hidden

Within a containing DIV, I have a collection of images. The DIV is absolutely positioned to the right of its container. My goal is for the images to flow horizontally when they exceed the width of the parent container, but remain hidden so that I can scrol ...

Issues with the functionality of Angular 2 routerLink

Unable to navigate from the homepage to the login page by clicking on <a routerLink="/login">Login</a>. Despite reviewing tutorials and developer guides on Angular 2 website. Current code snippet: index.html: <html> <head> ...

I am having trouble with the Bootstrap 5 column not functioning properly within my design

Currently working on a project with Bootstrap, where I am trying to create a footer that looks like the one in the image below: https://i.stack.imgur.com/XIbDk.png Below is the HTML code snippet for my footer: <footer class="footer"> <div class ...

Converting HTML data attributes to JSON: A step-by-step guide

A hypothetical scenario: Consider the following HTML element <div id="x" data-id='1' data-prop1='peace' data-prop2='out'>Text</div> In jQuery, you can extract the data like this var row = $('#x') var ...

CSS - Customizing the appearance of consecutive child divs

I'm struggling with adjusting the margin between two child divs when they follow each other. The current margin is set at 3rem, but I want it to be 1rem if both child containers have the class "narrow": Is there a way to achieve this without changing ...

Ensuring a fixed table with vertical scrolling only, no horizontal scrolling, while scrolling in either direction

I'm working with an HTML fixed design that contains a center-aligned table with extensive data scrollable both vertically and horizontally. To address the issue of keeping column headers visible when scrolling vertically, I used jQuery's clone() ...