The CSS3 Animation-fill-mode: An Essential Property

I am working on a cool effect where text slides into the window and remains in place after the animation is complete. Surprisingly, I have managed to get the animation to work on one part of the text, but for some reason, the second part is not cooperating.

Feel free to check out my code snippet on https://jsfiddle.net/9fpryou8/

Thank you in advance!

figure h2.world {
  position: absolute;
  top: 20%;
  left: 61%;
  background-color: transparent;
  font-size: 7em;
  color: white;
  font-family: Paytone One, Verdana, sans-serif;
  transform: translateX(300%);
  text-shadow: 0px 0px 50px black;

  -moz-animation-name: slideWorld;
  -moz-animation-iteration-count: 1;
  -moz-animation-timing-function: ease-in;
  -moz-animation-duration: 0.4s;
  -moz-animation-delay: 1.4s;
  -moz-animation-fill-mode: forwards;

  -webkit-animation-name: slideWorld;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function: ease-in;
  -webkit-animation-duration: 0.4s;
  -webkit-animation-delay: 1.4s;
  -webkit-animation-fill-mode: forwards;

  animation-name: slideWorld;
  animation-iteration-count: 1.4;
  animation-timing-function: ease-in;
  animation-duration: 0.4s;
  animation-delay: 1.4s;
  animation-fill-mode: forwards;
}

Answer №1

To modify the styling in the .world section, make the following change:

animation-iteration-count: 1;

figure {
    height: 98vh;
    background-color: grey;
}
figure h2.hello {
  position: absolute;
  top: 20%;
  left: 39%;
  font-size: 1em;
  background-color: transparent;
  color: white;
  font-family: Paytone One, Verdana, sans-serif;
  transform: translateX(-400%);
  text-shadow: 0px 0px 50px black;

  -moz-animation-name: slideHello;
  -moz-animation-iteration-count: 1;
  -moz-animation-timing-function: ease-in;
  -moz-animation-duration: 0.4s;
  -moz-animation-delay: 1s;
  -moz-animation-fill-mode: forwards;

  -webkit-animation-name: slideHello;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function: ease-in;
  -webkit-animation-duration: 0.4s;
  -webkit-animation-delay: 1s;
  -webkit-animation-fill-mode: forwards;

  animation-name: slideHello;
  animation-iteration-count: 1;
  animation-timing-function: ease-in;
  animation-duration: 0.4s;
  animation-delay: 1s;
  animation-fill-mode: forwards;
}

figure h2.world {
  position: absolute;
  top: 20%;
  left: 61%;
  background-color: transparent;
  font-size: 1em;
  color: white;
  font-family: Paytone One, Verdana, sans-serif;
  transform: translateX(300%);
  text-shadow: 0px 0px 50px black;

  -moz-animation-name: slideWorld;
  -moz-animation-iteration-count: 1;
  -moz-animation-timing-function: ease-in;
  -moz-animation-duration: 0.4s;
  -moz-animation-delay: 1.4s;
  -moz-animation-fill-mode: forwards;

  -webkit-animation-name: slideWorld;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function: ease-in;
  -webkit-animation-duration: 0.4s;
  -webkit-animation-delay: 1.4s;
  -webkit-animation-fill-mode: forwards;

  animation-name: slideWorld;
  animation-iteration-count: 1;
  animation-timing-function: ease-in;
  animation-duration: 0.4s;
  animation-delay: 1.4s;
  animation-fill-mode: forwards;
}
<figure>
  <h2 class="hello">Hello</h2>
  <h2 class="world">World</h2>
</figure

You can also choose to simply remove it: the default value of animation-iteration-count is 1.

Answer №2

There seems to be a small error in your typing.

Please update animation-iteration-count: 1.4; to animation-iteration-count: 1;

Once you make this change, everything should function correctly.

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

What is the best way to format a string to display the second value in the string?

I have successfully combined the currency and value columns into one column displaying USD 20000. Now I am looking to format the value string to appear as USD 20,000. However, I am unsure of how to incorporate property.DisplayFormatString into the second s ...

"Retrieve the position of a contenteditable element while also considering HTML

I've been exploring a method to generate annotations within HTML text using JavaScript. The approach involves the user clicking on a contenteditable <div> and obtaining the cursor's position based on their click. Subsequently, when insertin ...

Switching between different CSS files based on the URL using jQuery or another method

Is it feasible to apply specific styles based on the ID or load various CSS files depending on the URL you are visiting? For example: <script> if(location.href == 'http://jpftest2.tumblr.com/about'){ document.write('<style type= ...

Refresh your webpage automatically without the need to manually refresh after clicking a button using AJAX in HTML and PHP!

One issue I'm facing is that the page doesn't auto-refresh, although it loads when I manually refresh it. Below you can find my HTML and AJAX code along with its database details. The Trigger Button <?php $data = mysqli_ ...

What is the best way to retrieve the current URL with a hashtag symbol using JavaScript?

I am attempting to display the current URL after the question mark with a hash symbol using PHP, but unfortunately, it is not achievable. Therefore, I need to utilize JavaScript for this task, even though I have limited knowledge of it. This is the specifi ...

Address Book on Rails

Hello, I'm relatively new to this and would be grateful for any assistance. My goal is to utilize the data saved by a user in their address book, and then offer them the option to use that address for delivery. Below is my Address controller: class A ...

What is preventing my HTML/CSS code from generating a button on the webpage?

There seems to be an issue with the image on my webpage - it's displaying a broken page icon instead of the actual image, even though it was showing fine before. The image name and location have not been changed. I'm also having trouble creating ...

What could be the reason for the route animation failing to work in Angular2?

App.module: import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from "@angular/http"; import { BrowserAnimat ...

Node.js web application encounters ECONNRESET and MongoNetworkError issues

Currently working on a website with Node.js, Express, and MongoDB (MLAB). The code is too long to post here. When I try to access my index page, app.get("/alumniport", (req, res) => { alumni.find((err, theAlumni) => { if (err) { res.redi ...

A guide to customizing the list-style-image for unordered lists in Weebly

I encountered an issue while trying to create a page on Weebly. Whenever I attempt to customize my 'ul' tag in the following way: #top-home-wrap #main #content ul { color: yellow; list-style-image: url('fa-check.png') !important; } T ...

Label alignment in one line with responsive checkbox

Could someone assist me with adjusting the alignment of this checkbox when resizing the window for mobile view? The label text is breaking into a new line while the checkbox remains in its original position. How can I make the checkbox align closer to its ...

Create a JavaScript/jQuery function that causes an element to fade in when the mouse is

I am currently developing a PHP/MySQL project that involves creating a function to display a brief description when a user hovers over an image. However, I seem to be encountering an issue where the function crashes after a few uses. Below is a snippet of ...

What is the best way to stop event bubbling in react-router-dom when using the <Link> component?

Hey there! I have a situation that I need help with. I tried putting the Link around the whole post so that I could prevent bubbling for individual buttons, but for some reason stopPropagation() is not working as intended. Following advice from another s ...

Using jQuery's .html function to insert images

I have a unique counter that counts in currencies, such as Yen and Euro. Each number, as well as the currency sign and separator, are all displayed on the webpage using custom-designed icons. I utilize the display: flex; property in my container div and ap ...

What steps do I need to follow to change the background color to white for the <App/> component in solid-js?

In my solid-js application styled with tailwindcss, I established a gray color in the index.css for the background of various screens. However, I wanted the main <App/> component to have a white background instead. To achieve this, I created an App.c ...

What are the benefits of incorporating CSS into a CSS block rather than utilizing inline output with HtmlHelper in CakePHP?

Just a few days ago, I embarked on the journey of learning CakePHP through their blog tutorial. Now, I am diving into writing my own small project to gain hands-on experience with the framework. After going through their documentation, I discovered two ...

How can I fetch a value from a database and set it as the selected option in a

I am facing an issue with the usage of the selectpicker plugin from Bootstrap in order to select multiple items. My requirement is to create a modal for editing where the data is fetched from previous records, particularly an array. I am looking for a way ...

What are the steps for submitting a form with AJAX?

I am having trouble submitting a form via ajax. I am not receiving any error messages even though I have set up error handling throughout the website. Here is my code: <script type="text/javascript" src="jquery.js"></script> <div id="shower ...

Image container unable to resize to fit within a CSS grid cell

I'm currently working on organizing a CSS grid for my images on a tribute page project from free code camp. I was able to set up the grid as intended, but I am facing some difficulties in making the images fit perfectly within each cell. Some images a ...

When the react autocomplete dropdown appears, it pushes other input elements downward, affecting their

Having implemented an autocomplete dropdown feature by following this link, I am encountering an issue with displaying the dropdown items. As shown in the reference link, the dropdown items are rendered within a div tag with the position set to relative. ...