Troubleshooting: CSS Animation issue with fade in and transform effects on individual words

I want to achieve a cool effect where each word starts at 0 opacity and translateY(65px), then fades in one word at a time while transitioning to translateY(0). Although the words are fading in, they are not translating as desired. For reference, check out this example: (scroll down to paragraph)

var $el = $(".example:first"), text = $el.text(),
    words = text.split(" ");

var html = "";
for (var i = 0; i < words.length; i++) {
    html += "<span>" + words[i] + " </span>";
};
$el.html(html).children().each(function(i){
  $(this).addClass('fadeInUp');
});
@keyframes fadeInUp{
    0%{
    transform: translateY(65px);
    opacity: 0;
    }
    100%{
        opacity:1;
        transform:none;
    }
}
.fadeInUp{
    transition: opacity .5s ease-in-out,transform .8s ease-in-out,-webkit-transform .8s ease-in-out;
    animation:fadeInUp 3s forwards;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="example">
    These are some words that should be faded in and transformed one after the other.
</div>

Answer №1

To enable the transform function to work properly, you must adjust the display property:

var $el = $(".example:first"), text = $el.text(),
    words = text.split(" ");

var html = "";
for (var i = 0; i < words.length; i++) {
    html += "<span>" + words[i] + " </span>";
};
$el.html(html).children().each(function(i){
  $(this).addClass('fadeInUp');
});
@keyframes fadeInUp{
    0%{
    transform: translateY(65px);
    opacity: 0;
    }
    100%{
        opacity:1;
        transform:none;
    }
}
.fadeInUp{
    transition: opacity .5s ease-in-out,transform .8s ease-in-out,-webkit-transform .8s ease-in-out;
    animation:fadeInUp 3s forwards;
    display: inline-block;
    margin-right: 6px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="example">
    These are some words that should be faded in and transformed one after the other.
</div>

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

Why is fading out columns in an HTML table with jQuery's .fadeTo() method taking so long?

I am looking to implement a functionality where all cells in a column of my HTML table fade out when I click on a button located in the header of that column. I have written the following JavaScript code to achieve this: ... myDOMElement.find(".headerIcon ...

Button to access overlay menu on my map with OpenLayers 3

I am trying to add a menu button on top of my map that, when clicked, will display a window. I have created the map div and the overlayMenu button div, but unfortunately, the button is not showing up where I want it to. I would like the button to be locate ...

Find out the dimension of an object's width

I have a container that I want to slide in and out of view on the screen when a button is clicked. The challenge is that I do not want to set a specific width for the container as it may vary in size. I attempted to achieve this with the following code, ...

What steps should I follow to create an automatic image slider using Fancybox that transitions to the next slide seamlessly?

*I've recently ventured into web design and am currently experimenting with Fancybox. I'm interested in creating a slider with 3 images that automatically transitions to the next image, similar to what is seen on this website: Is it feasible to ...

Tips for enabling a flexbox item to extend beyond its container

While attempting to utilize flexbox for creating a navbar with the logo in the center, I encountered an issue where the logo wasn't able to overflow from above and below the navbar. I experimented with squeezing in and positioning the element, but it ...

When scrolling through a page, the MySQL data being loaded via an ajax/jquery call is not displaying the accurate information

Currently, I am facing an issue with loading data from a MySQL database onto a webpage using AJAX/jQuery call. The problem lies in receiving duplicate data that has already been fetched and displayed on the page. I believe there is nothing wrong with the s ...

Guide on determining the total count based on a specific condition with the help of jQuery

Using AJAX, I have successfully retrieved all status values such as Active, ACTIVE_DRAFT, and Pending. However, I only want to select the statuses that are equal to ACTIVE. To do this, I am using an if condition which is working fine. After filtering by st ...

The issue with Ajax functionality in Laravel persists

I have been attempting to implement a basic Ajax call within my web application, but unfortunately, it is not functioning as expected. HTML Code <li id="decorative_items"> Decorative Items </li> Ajax Code: $(document).ready(function() { ...

What is the reasoning behind next.js requiring the use of modular CSS instead of a global stylesheet linked to each page?

I am currently attempting to include a minified link stylesheet created with sass:watch into a particular page of a next.js (13) project. However, upon adding it using the head component, I received this warning: Do not add stylesheets using next/head I ...

The jquery fancybox ajax modal popup fails to display in Internet Explorer 7

Recently, I utilized JQuery fancy box for the first time to display a menu list. When clicking on a specific item, the page is rendered properly in an iframe. However, if there is already an AJAX model popup present on the rendered page, it doesn't di ...

Is it better to choose AJAX and JQuery for their speed and complexity, or stick with the simplicity of GET requests?

When a user attempts to log in and fails, an error message should be displayed on the page. There are two primary methods that can be used to achieve this: one involves using a form action on the HTML page and handling incorrect login information in the PH ...

Tips for positioning an image in the TOP Right corner below the navbar using CSS

I am currently in the process of learning HTML and CSS, and I would like to practice and conduct research whenever I encounter difficulties. Recently, I have been attempting to style my landing page based on a screenshot that I took. However, I have been u ...

Ensure that hyperlinks remain unbroken and do not split over two lines

When I generate links using $_GET [Array] to display in a box, I aim to have 5-10 links per line without any of them appearing on two lines. While I currently use {text-align:justify;} for consistent border spacing, I am seeking a method to prevent the lin ...

Encountering an error when trying to parse JSON response in an AJAX request, showing as

When I send an AJAX request to my GPS server, it returns JSON data in the following format if successful: {"result":[{"longitude":76.391529,"latitude":27.974347,"location":"Delhi-Ajmer Expressway - Madhosinghpura- Alwar - Rajasthan - India","speed":0,"dtt ...

Delete a class that is not identified by the DOM

Currently, I'm developing an interactive map that triggers an overlay image to highlight the selected area. I am trying to dynamically add and remove classes from a div based on the highlighted area. Initially, I attempted using the starts with selec ...

Adding a CSS style to a specific child element

Here is an example snippet <html> <head> <style> .test > input { //this selector is incorrect. color:red; } </style> </head> <body> <div class="test"> <di ...

Functioning Ajax Jquery form functionality

I've come across an issue while working on some jquery processes. It seems that the code I'm using doesn't work when a specific line is commented out, but works perfectly fine when uncommented. Can anyone shed some light on why this might be ...

analyzing JSON information

Upon receiving a response in the $.ajax success method, I encountered the following: {\"ID\":18,"TSName":"testSuit"} I'm wondering how to properly parse it using the following code: success: function (response) { var tr = response.d; ...

What sets apart Firefox and Chrome when it comes to interpreting the widths of flex items?

Looking to create a column layout using flexbox with three divs that span the full width of their parent container while maintaining a single line height. If the content in the center div overflows, I want it to display an ellipsis at the end. Check out t ...

angularjs bootstrap carousel not functioning as expected

HTML How do I apply an active class to the first image? I am trying to create a slideshow with images from a database but encountering issues. <div id="myCarousel" class="carousel slide" data-ride="carousel"> <div ...