"Bootstrap's animated & overlayed form elements"
Bootstrap 3.3.0 Snippet by AtiqUrRehman

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container" id="form">
<h2 class="h2">Bootstrap's animated & overlayed form elements</h2>
<p>
The base about form elements the structure still the bootstrap structure, with a <code>.form-group</code> composed of a <code>label</code> and a <code>input.form-control</code>.
</p>
<div class="panel panel-default showcase">
<div class="panel-body">
<div class="form-group">
<label for="#form-control-1">Example 1</label>
<input class="form-control" id="form-control-1" type="text">
</div>
</div>
</div>
<p>
For using the animated version, just add the variant class <code>.-animated</code> on the <code>.form-group</code> element
</p>
<div class="panel panel-default showcase">
<div class="panel-body">
<div class="form-group -animated">
<label for="#form-control-2">Example 2</label>
<input class="form-control" id="form-control-2" type="text">
</div>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
.form-control {
display: block;
width: 100%;
height: 50px;
font-size: 14px;
color: #262732;
background-color: transparent;
background-image: none;
border: 1px solid #66B0CB;
border-radius: 3px;
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
-moz-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}
textarea {
max-width: 100%;
}
label {
margin-bottom: 0;
font-weight: 700;
color: #7BCC70;
text-align: center;
display: block;
font-size: 16px;
line-height: 19px;
margin-bottom: 11px;
}
.form-control {
text-align: center;
font-size: 16px;
z-index: 1;
position: relative;
border-width: 2px;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$(function(){
$('.form-group.-animated .form-control, .form-group.-overlayed .form-control').keyup(function(event) {
if ($(this).val() != '') {
$(this).parent('.form-group').addClass('-active');
} else {
$(this).parent('.form-group').removeClass('-active');
}
});
$('.form-group.-animated .form-control, .form-group.-overlayed .form-control').focusin(function(event) {
$(this).parent('.form-group').addClass('-focus');
});
$('.form-group.-animated .form-control, .form-group.-overlayed .form-control').focusout(function(event) {
$(this).parent('.form-group').removeClass('-focus');
});
})
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: