CSS animation similar to Mac OS X 10.8 invalid password “shake”?

前端 未结 2 1478
借酒劲吻你
借酒劲吻你 2021-02-02 10:21

On the Mac OS X 10.8 \"password\" screen, if you enter an invalid password, it will \"shake\" back and forth (a.k.a. left and right). I am trying to achieve an similar effect f

相关标签:
2条回答
  • 2021-02-02 10:51

    I'd give jRumble a shot too, it has a very large set of shakes and they can be combined to make all sorts of crazy stuff happen. Some fun examples:

    • Shake based on a percentage
    • Time based shake
    0 讨论(0)
  • 2021-02-02 11:06

    I used my iPad camera to record the Mac pasword screen. It looks like it shakes 3 times each direction, with the first 2 going the full distance and the last 1 time a lesser distance.

    #demo-password.invalid {
        outline-color: red;
        /* also need animation and -moz-animation */
        -webkit-animation: shake .5s linear;
    }
    /* also need keyframes and -moz-keyframes */
     @-webkit-keyframes shake {
        8%, 41% {
            -webkit-transform: translateX(-10px);
        }
        25%, 58% {
            -webkit-transform: translateX(10px);
        }
        75% {
            -webkit-transform: translateX(-5px);
        }
        92% {
            -webkit-transform: translateX(5px);
        }
        0%, 100% {
            -webkit-transform: translateX(0);
        }
    }
    
    0 讨论(0)
提交回复
热议问题