"Trouble with the functionality of Animate.css fliptext when triggered by button click

I want to implement a flip animation on text when a button is clicked. I am using the 'flipInY' animation from animate.css library, but it's not working as expected. The desired animation can be seen in the example provided in this link:

Here is the code snippet where I want to apply the same animation:

<html>
<head>
    <title></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css">
</head>
<body>
    <div>
        My Name is <h1 id="txt">It Works!</h1> Hardik
    </div>
    <button type="button" id="btn">Animate</button>
    <script src="https://code.jquery.com/jquery-2.2.4.min.js" type="text/javascript"></script>
    <script>
        $.fn.extend({
            animateCss: function (animationName) {
                var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
                $(this).addClass('animated ' + animationName).one(animationEnd, function () {
                    $(this).removeClass('animated ' + animationName);
                });
            }
        });
        $("#btn").click(function () {
             $('#txt').animateCss('flipInY');
        });
    </script>
</body> 
</html>

I have also shared a CodePen demo of the implementation here:
http://codepen.io/anon/pen/bwGdvO

Answer №1

It seems like the issue you're facing can be easily solved.

Currently, the animation is affecting the entire header container, which stretches across the width of the page.

To fix this, you can wrap the text within the header in a div/span with display:inline-block; and apply the animation to that specific element instead.

You can take a look at the updated CodePen here: http://codepen.io/anon/pen/rrNOjW

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 are the best ways to enhance performance for ajax requests using Jquery?

Currently, I am in the process of developing a mobile application that utilizes jquery mobile, jquery, and a PHP backend. My issue arises when dealing with certain pages as there are numerous ajax requests being sent and received simultaneously, resulting ...

Dynamic layout problem with navigation pills

I currently have 2 navigation pill buttons designed to alter the layout upon being clicked. Both layouts always include the sidebar which remains constant throughout. Clicking on Nav pill 1 will display the layout as follows: sidebar | column 1 | column ...

Retrieve the concealed division element's HTML content along with its formatting

Help needed with appending a hidden div with its styles intact. Despite using the code provided below, the appended div does not retain its styles. Any suggestions for an alternative method? var warningMessage = $('#warningDiv').html() fun ...

Bootstrap 5 dual carousel focus

I have implemented a combo carousel that serves as a timeline slider and displays 14 dates. Along with thumbnails, I am also using dates for navigation. To handle the large number of dates, I need to display them in separate rows, but only show one row at ...

Is there a way to modify the appearance of a text box to suit individual preferences?

Is it possible to alter the shape of a text box, creating a rectangle with a portion removed from one side? I have included an example image for reference. https://i.sstatic.net/oNyum.png I came across clip-path: polygon in CSS, but it seems to only accep ...

displaying JSON data in two separate Highcharts bar charts

Looking to display data using a bar highcharts, with only two bars, each with data... Here's the breakdown: I have a bar chart with 2 categories, each containing subcategories. Here are the data for the categories: First category: subCategory 1-1 ...

Issue with Firefox browser: Arrow keys do not function properly for input tags in Twitter Bootstrap drop down menu

Requirement I need to include a login form inside the dropdown menu with username and password fields. Everything is working fine, except for one issue: Issue When typing, I am unable to use the arrow keys (up/down) in Firefox. This functionality works ...

The function .get() is expecting callback functions, however it received an undefined object at route.(anonymous function) as get[]

Hey everyone, I've encountered an error in my server.js file and being a beginner I'm struggling to find a solution. I've searched through numerous answers on Stack Overflow but haven't been able to resolve it. Can someone please help m ...

Unnecessary list elements generated by dazzling navbarPage

While developing an app with shiny using navbarPage, I noticed that there are some unwanted li tags in the HTML that are not defined in my code. Could this be a known bug? How can I go about fixing it? <nav class="navbar navbar-default navbar-stati ...

Encountering repetitive actions during the processing of the MVC controller operation

Currently, I'm making an ajax request to my controller for processing. However, when I look at the message in my ajax done function, it displays two outcomes. The output from console.log is: {"result_code":1,"result_message":"Contact tags deleted"," ...

Tips for efficiently printing invoices on specific paper: Print a maximum of 20 items per sheet, and if it exceeds this limit, continue onto the next page. Ensure the total amount is

$(document).ready(function(){ var j = 23; for (var i = 0; i < j+11; i++) { if (i != 0 && i % 11 == 0) { $("#printSection div").append("<?php echo '<tr><td>fff</td></tr>'; ?>"); ...

Difficulty in adjusting the height of the popover menu that appears when using the Select Validator in Material UI

I am having trouble adjusting the height of a popover that emerges from a select validator form in Material UI. Despite attempting various methods, including adding the following CSS to the main class: '& .MuiPopover-paper': { height: &apos ...

JavaScript code is experiencing issues following a for loop

I recently developed a code to upload resized images using HTML and JavaScript. Here is the HTML form setup: <form action="aa.php" method="post" id="uploadImageForm" enctype="multipart/form-data"> <input type="file" id="fileToUploadId" ...

Aligning the toggle menu in the center when it is collapsed

Hello everyone, I am new to Bootstrap 4 and struggling to figure out how to center the toggle menu on mobile devices. Can anyone provide some guidance or solutions on how to achieve this? Here's an example of what I'm aiming for. <body> ...

What is the best approach for dynamically updating JSON values using user input in jQuery?

I have implemented a feature where users can enter values into 3 text boxes and upon clicking the add button, these values are added to a new JSON object and displayed in a table. Additionally, users can edit specific fields in the table which should updat ...

Tips for Resizing google reCAPTCHA

The problem's image is shown below: https://i.sstatic.net/ph2EX.jpg Below is the code snippet related to the issue: <div class="text-xs-center" id="DIVCATCHA" runat="server"> <asp:HiddenField runat="server" ID="hdnImageSelected" /> ...

Looking for assistance with implementing jQuery UI autocomplete feature

Currently, I am attempting to integrate the jQuery UI autocomplete feature into a CodeIgniter project. At this point, I have an input field: <input type="text" id="text1"/> Then in my script, the code looks like this: source: function(request, res ...

The blinking cursor in Google Docs is known as "kix-cursor-caret."

Although I adore Google Docs, I can't help but find the blinking cursor a bit too distracting for my liking. It seems that the latest version of Google Docs fails to comply with the operating system's setting for displaying a solid, non-blinking ...

Displaying a pop-up message in Rails upon modifying a Model

Would it be feasible to implement the ActiveRecord Callbacks before_create after_create before_save after_save before_destroy after_destroy in order to showcase notifications to the user using jQuery? Could someone possibly share an example?? Appreci ...

Best Practices for CSS Naming in MVC Architecturelayouts

Creating a CSS naming convention within an MVC Project with Layouts can be a challenging task. The use of Layouts introduces the necessity of being cautious when selecting class names, as they could potentially be overridden by classes declared in the Lay ...