Shake a login form on error

前端 未结 9 1199
猫巷女王i
猫巷女王i 2020-12-21 02:39

I have successfully built a login form using ajax and want to add a shake effect to the form when the user enters incorrect details. I have the function in place that will f

9条回答
  •  一个人的身影
    2020-12-21 03:17

    For those of you who are stubborn (like me) and hate libraries...

    var e = document.getElementById('dividname');
    e.style.marginLeft='8px';
    setTimeout(function(){e.style.marginLeft='0px';},100);
    setTimeout(function(){e.style.marginLeft='8px';},200);
    setTimeout(function(){e.style.marginLeft='0px';},300);
    

    then in your css:

    .shakeClass{
       transition: margin 100ms;
    }
    

提交回复
热议问题