Skip to content

Instantly share code, notes, and snippets.

@carmark
Created March 9, 2019 11:29
Show Gist options
  • Save carmark/cc3e49488148bc766ef2ac06b6e45415 to your computer and use it in GitHub Desktop.
Save carmark/cc3e49488148bc766ef2ac06b6e45415 to your computer and use it in GitHub Desktop.
Login form shake effect
<div class="login-form">
<h1>Vini</h1>
<div class="form-group ">
<input type="text" class="form-control" placeholder="Username " id="UserName">
<i class="fa fa-user"></i>
</div>
<div class="form-group log-status">
<input type="password" class="form-control" placeholder="Password" id="Passwod">
<i class="fa fa-lock"></i>
</div>
<span class="alert">Invalid Credentials</span>
<a class="link" href="#">Lost your password?</a>
<button type="button" class="log-btn" >Log in</button>
</div>
$(document).ready(function(){
$('.log-btn').click(function(){
$('.log-status').addClass('wrong-entry');
$('.alert').fadeIn(500);
setTimeout( "$('.alert').fadeOut(1500);",3000 );
});
$('.form-control').keypress(function(){
$('.log-status').removeClass('wrong-entry');
});
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
@import "compass/css3";
@import url(https://fonts.googleapis.com/css?family=Vibur);
*{
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
font-family:arial;
}
body{background:#FF9000;}
h1{
color:#ccc;
text-align:center;
font-family: 'Vibur', cursive;
font-size: 50px;
}
.login-form{
width:350px;
padding:40px 30px;
background:#eee;
@include border-radius(4px);
margin:auto;
position: absolute;
left: 0;
right: 0;
top:50%;
@include translateY(-50%);
}
.form-group{
position: relative;
margin-bottom:15px;
}
.form-control{
width:100%;
height:50px;
border:none;
padding:5px 7px 5px 15px;
background:#fff;
color:#666;
border:2px solid #ddd;
@include border-radius(4px);
&:focus, &:focus + .fa{
border-color:#10CE88;
color:#10CE88;
}
}
.form-group .fa{
position: absolute;
right:15px;
top:17px;
color:#999;
}
.log-status.wrong-entry {
@include animation( wrong-log 0.3s);
}
.log-status.wrong-entry .form-control, .wrong-entry .form-control + .fa {
border-color: #ed1c24;
color: #ed1c24;
}
.log-btn{
background:#0AC986;
dispaly:inline-block;
width:100%;
font-size:16px;
height:50px;
color:#fff;
text-decoration:none;
border:none;
@include border-radius(4px);
}
.link{
text-decoration:none;
color:#C6C6C6;
float:right;
font-size:12px;
margin-bottom:15px;
&:hover{
text-decoration: underline;
color:#8C918F;
}
}
.alert{
display:none;
font-size:12px;
color:#f00;
float:left;
}
@include keyframes (wrong-log) {
0%, 100% { left: 0px;}
20% , 60%{left: 15px;}
40% , 80%{left: -15px;}
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment