Rumah >hujung hadapan web >html tutorial >纯css简单的警告框加抖动效果_html/css_WEB-ITnose
这种效果的警告框,出错了会抖动
.alert-box { width: 400px; border-style: outset; position: relative; color:#555; border-radius:10px; font-family:Tahoma,Geneva,Arial,sans-serif;font-size:11px; padding:10px 10px 10px 10px; margin:auto; display: none; } .alert-box span { font-weight:bold; text-transform:uppercase; } .error { background:#ffecec no-repeat 10px 50%; border:1px solid #f5aca6; }
jQuery的动画效果,animate for循环4次左右移动
var $box = $('.alert-box'); $box.html('<span>error: </span>' + data.error); $box.show(); var box_left = ($(window).width() - $box.width()) / 2; for(var i=1; 4>=i; i++){ $box.animate({left:-(40-10*i)},50); $box.animate({left:+2*(40-10*i)},50); }