Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS animation not working on span with animate.css

I have a <button> and a <span> inside a tab. I want to add animate.css classes to span when hover over button. I'm using angular to include them.

It doesn't work in chrome (it does work in ie):

<div>
    <button ng-mouseover="one()" ng-mouseleave="two()">Hover over me</button>
    <span ng-class="{animated : zero, bounce : zero}">Animate me</span>
</div>

<script>
    function controlTotal($scope) {

        $scope.zero = false;

        $scope.one = function () {
            $scope.zero = true;
        };

        $scope.three = function () {
            $scope.zero = false;
        };

    };
</script>
like image 473
Facutz Avatar asked Jun 09 '16 15:06

Facutz


People also ask

Why is my animate CSS not working?

By default, a CSS animation cycle is zero seconds long. To override this, add an animation-duration rule to your targeted element with a seconds value, in the same block as animation-name. Below, try removing the comments around animation-duration to fix the animation.

Which CSS properties Cannot be animated?

CSS properties that define animation parameters such as animation-direction and animation-name are not animatable because animating them would create complex recursive behavior.

Can you have two animations CSS?

Setting multiple animation property valuesThe CSS animation longhand properties can accept multiple values, separated by commas. This feature can be used when you want to apply multiple animations in a single rule and set different durations, iteration counts, etc., for each of the animations.

Is it better to animate with CSS or JavaScript?

In summary, we should always try to create our animations using CSS transitions/animations where possible. If your animations are really complex, you may have to rely on JavaScript-based animations instead.


1 Answers

Use display:inline-block; with the span:

<span style="display:inline-block;" 
    ng-class="{animated : zero, bounce : zero}">Animate me</span>

Animate.css GitHub:

Historically, span elements can't be animated with CSS. In order to animate them, you'll need to give them a display property. Obviously display: block; will give you undesirable effects, so assigning display: inline-block would be a better choice, and solve the issue.

like image 145
Jaqen H'ghar Avatar answered Sep 22 '22 13:09

Jaqen H'ghar