Bootstrap snippet and html example. Floating label css

This html snippet was created to help web designers, web developers, front-end and back-end developer save time. Use it for free in your project and build your app faster, You can also download the HTML, CSS, and JS code.
Tags: form,label

HTML code

This is the html code used to create this bootstrap snippet, You can copy and paste the following html code inside a page with bootstrap 3.3.6 included, to get the result that you can see in the preview selection

<div class="container">
    <div class="jumbotron">
		<h1>Floating label css</h1>
	</div>
    
    <div class="col-md-5 col-md-offset-1">
		<form role="form"  id="floating-label">
		
			<div class="form-group">
				<label class="control-label">First Name</label>
				<input type="text" class="form-control" />
			</div>

			<div class="form-group">
				<label class="control-label">Last Name</label>
				<input type="text" class="form-control"/>
			</div>
		
		</form>
	</div>

</div>

CSS code

This is the css code used to create this bootstrap snippet, You can copy and paste the following css code inside a page with bootstrap 3.3.6 included, to get the result that you can see in the preview selection

body{margin-top:20px;}

#floating-label .form-group {
    									display: flex;
										height: 55px;
									}

									#floating-label .control-label {
										font-size: 16px;
										font-weight: 400;
										opacity: 0.4;
										pointer-events: none;
										position: absolute;
										transform: translate3d(6px, 22px, 0) scale(1);
										transform-origin: left top;
										transition: 240ms;
									}

									#floating-label .form-group.focused .control-label {
										opacity: 1;
										transform: scale(0.75);
									}

									#floating-label .form-control {
										align-self: flex-end;
									}

									#floating-label .form-control::-webkit-input-placeholder {
										color: transparent;
										transition: 240ms;
									}

									#floating-label .form-control:focus::-webkit-input-placeholder {
										transition: none;
									}

									#floating-label .form-group.focused .form-control::-webkit-input-placeholder {
										color: #bbb;
									}

Javascript/Jquery code

This is the javascript code used to create this bootstrap snippet, You can copy and paste the following javascript code inside a page with bootstrap 3.3.6 included, to get the result that you can see in the preview selection

$('.form-control').on('focus blur', function (e) {
    	$(this).parents('.form-group').toggleClass('focused', (e.type === 'focus' || this.value.length > 0));
	}).trigger('blur'); 

Similar snippets

Bootstrap example and template. contact page section

contact page section

Bootstrap example and template. payment credit card form

payment credit card form

Bootstrap example and template. Highlight textbox instead of error message using jquery validations

Highlight textbox instead of error message using jquery validations

Bootstrap example and template. form inputs

form inputs

Bootstrap example and template. bs5 dark footer

bs5 dark footer

Bootstrap example and template. Whatsapp web chat template

Whatsapp web chat template

Bootstrap example and template. animated chat window

animated chat window

Bootstrap example and template. media profile

media profile

Bootstrap example and template. Floating label css

About this bootstrap example/template

We hope you will enjoy this awesome snippet and stay tuned for the latest updates, bootdey snippets are already used in thousands of blogs, websites and projects. We believe it will save your precious time and gives trendy look to your next web project.

We always try to offer the best beautiful and responsive source of Bootstrap code examples and components.

This code example currectly have 9.5K views, Using this bootstrap snippet you have the following benefits:

Bootstrap 3.3.6

<link rel='stylesheet' href='https://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>

<script src='https://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'></script>

This code example is based on bootstrap 3.3.6 and the grid system of this framework

Responsive

Based on bootstrap framework makes all the layouts perfectly responsive for all devices

Crossbrowser compatibility

Tested on all major browsers, it works smoothly on all of them

Jquery plugins

Great built-in plugins with jquery framework, you can easy to change all declarations

semantic html 5

Built on html / css3 the code quality is really amazing

Simple Integration

This code example can be simply integrated on existing sites and new ones too, all you need to do is copy the code and start working