Looping CSS text animation with typing effect

I am struggling with a CSS code that types out text, but it only does so once and I need it to repeat infinitely. Despite adding

animation-iteration-count: infinite;
, it still doesn't work as intended. Another issue is that it slows down at the end. How can I fix these problems? Here is my current code:

@keyframes typing {
from { width: 0 }
to { width: 100% }
}

.animation::before
.container{
display: inline-block;
}
.typed-out{
overflow: hidden;
border-right: .15em solid #990000;
white-space: nowrap;
animation-iteration-count: infinite;
animation:
typing 5s forwards;
width: 0;
}
<!DOCTYPE html>
<html dir="rtl" lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>

<title>Demo - Bootstrap 5 multilevel dropdown submenu sample</title>

<link
href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="16747979626562647766562338253824">[email protected]</a>/dist/css/bootstrap.rtl.min.css"
rel="stylesheet"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="13717c7c67606761726353263d203d21">[email protected]</a>/dist/js/bootstrap.bundle.min.js"
crossorigin="anonymous"
></script>

<link rel="stylesheet" href="./css/test.css" />
<script src="./js/test.js" type="text/javascript"></script>
<link href="https://fonts.googleapis.com/css?family=Dosis&display=swap" rel="stylesheet">

</head>
<body>
<style>

</style>
</head>
<body>
<div class="container d-flex justify-content-center align-items-center">
<div>
<h2 class="typed-out">This is a Typing Text</h2>
</div>
</div>
</body>
</html>

Answer №1

When utilizing the animation property, remember to include the animation-iteration-count syntax which specifies the number of iterations. If you omit this value, it defaults to 1. To create an infinite animation, simply add the keyword infinite after the animation property.

@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

.animation::before
.container{
  display: inline-block;
}
.typed-out{
  overflow: hidden;
  border-right: .15em solid #990000;
  white-space: nowrap;
  animation: typing 5s forwards infinite;
  width: 0;
}
<h2 class="typed-out">This is a Typing Text</h2>

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

Implementing Pagination or Infinite Scroll to Instagram Feed

Currently, I am working on creating an Instagram feed for a fashion campaign where users can hashtag their photos with a specific tag. Using the Instagram API, the script will pull all recent posts with this common tag to display on the webpage. Instagram ...

I seem to be having some issues with the functionality of .not() and it's

I am working on creating a menu that remains open for a set amount of time and then fades out if neither the parent nor the menu is hovered over. The goal is to have all other menus close when hovering over a new parent in the menu, but the current code k ...

Tips for incorporating Javascript in an innerHTML inline css situation

I'm just starting to learn about html5 and php. I'm curious about how to incorporate javascript into my existing code. Currently, I have data from a database displayed in an HTML table. My goal is to align the output of the last cell more toward ...

Tips on retrieving an object in a JavaScript function through an HTML event

The js function code is as follows: //Assigning the index of theater array to a variable $scope.setTheaterValue = function(name) { var index = $scope.path.map(function(s){return s.name}).indexOf(name); $scope.path = $scope.path[index]. ...

Combination of written content and mathematical equations displayed on an HTML webpage

I've been tasked with creating something similar to the following on an HTML page: The math tag in HTML is not suitable because it struggles with handling the line break between parts "/begin()-/end()". To achieve the desired effect (succes ...

jQuery: Automatically scroll to the end of the div based on the height of the content within

I have successfully developed a chat feature that is functioning perfectly. However, I am encountering an issue with making my div scroll to the bottom. The height of the div is calculated as calc(100% - 60px);. This particular div retrieves messages from ...

What could be causing the issue with my filter page not being able to retrieve any results from the

I am currently working on a filter page that is designed to display results in a table based on the selection made from a dropdown list. While I have written the necessary code and no errors are being detected, the results from the database are not showing ...

Is it possible to precisely position multiple children in a relative manner?

I am currently developing a custom dropdown menu where I want the parent element to be relatively positioned within the page. The goal is for all the child elements of the dropdown menu (the list items) to appear as if they are part of a select element and ...

What could be the reason behind a CSS caption overlapping another image within this table?

This is the CSS caption effect I am using: .cell { position: relative; width: 180px; height: 180px; } .caption {} .cell .caption { opacity: 0; text-decoration-color: gray; text-align: center; background: #eaeaea; position: absolute; fo ...

Side menu and grid display using HTML and CSS

Looking to revamp the layout of my angularJS website, specifically one page. Currently, information is displayed in a table format but I would like to switch it up by adding a left sidebar featuring a list of names (tiles). When a user clicks on a name, th ...

The ongoing battle between Carousel full page image slider and multi div slider in Bootstrap 4

I need a full-page carousel image slider in one div container and a multi-div slider in another div container on my homepage. Unfortunately, due to some conflicting class names (such as carousel slide, carousel-inner, etc.), they are interfering with each ...

display the table without providing a preview

Hey everyone, I am currently utilizing vue.js to develop a table and I am looking for a way to add a button that can print the data in the table without displaying a preview dialog. What modifications should I make to my javascript code in vue? Here is an ...

Guide to making a JavaScript button that triggers an iframe to open upon user clicking the button

I'm currently enhancing the comment section for posts on my website. I am looking to implement a button in javascript that, when clicked, will open an iframe window displaying comments similar to how Facebook does on their post. If there are other lan ...

Implementing a delay in a CSS menu design while still ensuring compatibility with browsers that do not support JavaScript

I currently have a three-tiered menu that relies on :hover and is controlled by css alone. I am now looking to introduce a slight delay to the hovers, which means transitioning my css :hovers to a .hover class and incorporating jQuery. My concern is whet ...

Webkit feature: Rounded border image overlay

One issue arises when applying a rounded border to an image in webkit browsers as the border ends up hidden behind the image. CSS img { border: 10px solid #000; border-radius: 100%; } HTML <img src="http://25.media.tumblr.com/tumblr_mbje ...

Tips for modifying CSS when a user scrolls beyond a specific div

Currently, I am working on implementing a scroll function that dynamically moves elements based on the user's scrolling behavior. The code I have written works to some extent and successfully moves the elements. However, my goal is to create a list o ...

Strange symbols were stored in the database after saving the textarea value

After submitting a form, text entered into a text area is being saved to my database. However, in one instance, certain characters such as • are appearing in the field. For example: • Text When retrieving the data from the database using Jav ...

Error: Unable to access the property 'fontSize' as it is undefined

<!DOCTYPE HTML> <html> <head> <title>Interactive Web Page</title> <link id="mycss" rel="stylesheet" href="mycss.css"> <script> function resizeText(size) { va ...

Issues with the styling of DIV elements

Currently tackling a project that involves numerous DIVs and sections, encountering an issue with the header. When I attempt to minimize the browser window, the search bar and panes div are not staying within the "header" section as expected. The structur ...

Utilize a combination of min-height percentages and pixels on a single div element

Currently searching for a method to explain min-height: 500px; min-height: 100%; the reason behind my decision to utilize this? The div must be either 100% in size or larger to allow for overflow. The height should only be set to 500px when the screen i ...