相关疑难解决方法(0)

CSS动画类似Mac OS X 10.8无效密码"摇"?

在Mac OS X 10.8"密码"屏幕上,如果输入无效密码,它将来回"摇动"(又称左右).我试图使用CSS动画为HTML密码输入字段实现类似的效果.

我创建了一个"密码摇动"jsfiddle似乎模仿了这种行为.但是,它似乎不太正确.我不确定明确的关键帧和linear计时功能是正确的方法.这是我第一次尝试CSS动画,我正在寻找有关实现这一目标的正确方法的反馈.

HTML

<div class="box">
    <input type="password" id="demo-password" placeholder="password" autofocus />
</div>
Run Code Online (Sandbox Code Playgroud)

JavaScript的

$('#demo-password').on('keyup', function (e) {
    var $input = $(this);
    var val = $.trim($input.val());
    $input.removeClass("invalid");

    if (e.which !== 13 || !val) {
        return;
    }

    if (val != "password") {
        $input.select();   
        $input.addClass("invalid");
    }
});
Run Code Online (Sandbox Code Playgroud)

CSS

#demo-password.invalid {
    outline-color: red;
    /* also need animation and -moz-animation */
    -webkit-animation: shake .6s linear;
}
/* also need keyframes and -moz-keyframes */
 @-webkit-keyframes shake {
    0% { …
Run Code Online (Sandbox Code Playgroud)

html macos user-interface css3 css-animations

24
推荐指数
1
解决办法
1万
查看次数

标签 统计

css-animations ×1

css3 ×1

html ×1

macos ×1

user-interface ×1