CSS3 Transition not working in Chrome anymore

你说的曾经没有我的故事 提交于 2019-12-07 01:46:48

问题


As far as I can remember, I didn't have any problems with the CSS3 transitions working for me, until now. Suddenly (possibly because of a chrome update or other modifications to my code) it has just stopped working in chrome (32.0.1700.77), but still works in all other browsers (and an older version of chrome).

@media screen and (max-width: 1325px) {
    .row-offcanvas {
        position: absolute;
        -webkit-transition: all 0.25s ease-out;
        -moz-transition: all 0.25s ease-out;
        transition: all 0.25s ease-out;
        width: 100%;
    }

    button.toggle {
        display: inline-block;
    }

    .row-offcanvas-left,
    .sidebar-offcanvas {
        left: -239px;
        z-index: 9999;
        height: 700px;
    }
    .row-offcanvas-left.active {
        left: 239px;
    }
    .sidebar-offcanvas {
        position: absolute;
        top: 0;
        width: 239px;
    }
}

I haven't made any changes to this part of the site and I can't explain why it might not work all of a sudden. The transition is for a panel which slides out when a button is clicked, triggered by this bit of javascript (not responsible for the animation).

$(document).ready(function() {
  $('[data-toggle=offcanvas]').click(function() {
    $('.row-offcanvas').toggleClass('active');
  });
});

回答1:


Your problem is that you are trying to animate from an undefined property: you are changing left to 239px, but don't explicitly specify it as 0 initially. It therefore defaults to auto, a value for which there is no valid smooth transition to 239px.

Add left:0 to the base definition and you will be fine.

See a JSfiddle here demonstrating your problem in Chrome 32+.



来源:https://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!