Animation and Transition in CSS Together Do not Run

1

I am writing the code below and the part of transition is not working.

The class .menu-fixed I apply via javascript. The animation when you open the site. The animation works, but when I apply the class containing transition it does not work.

Do not they work together on the same element?

CSS

            &.fundo-menu{
                position: absolute;
                left: 0;
                right: 0;
                top: -500px;
                opacity: 0;
                margin: auto;
                width: auto;
                animation-name: LogoTorcaneDesce;
                animation-timing-function: ease;
                animation-duration: 2s;
                animation-delay: 0.2s;
                animation-fill-mode: forwards;
                transition: all 0.8s ease;
                &.menu-fixed{
                    width: 230px;
                }
            }

JS

    var MenuHeaderBox = $("header#header, nav.menu, .fundo-menu, .logo-menu");
    $(window).scroll(function(){
        if($(this).scrollTop() > 300){
            MenuHeaderBox.addClass('menu-fixed');
        }else{
            MenuHeaderBox.removeClass('menu-fixed');
        }
    });
    
asked by anonymous 07.08.2015 / 18:59

1 answer

0

I discovered the problem. The transition does not work when I determine a auto value in the property.

In my case, I had width: auto . I changed the actual value of the image and transition worked.

I believe this is for all cases.

    
07.08.2015 / 19:07