Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>  
  <div class="icon third"><i class="fa fa-html5" alt="html5"></i></div>
  <div class="icon third"><i class="fa fa-css3" alt="css3"></i></div>
  <div class="icon third" alt="JS">JS</div>
  <h2 class="full"> ASIM edit: <em>Floating Labels</em> &nbsp; <i class="fa fa-twitter"></i> <a href="https://twitter.com/AntonSimanov" target="_blank">  @AntonSimanov</a></h2> 
</header>

<form action="">
  <!--  General -->
  <div class="form-group">
    <h2 class="heading full">General</h2>
    <div class="controls half">
      <input type="text" id="firstName" class="floatLabel" name="First Name">
      <label for="firstName">First Name</label>
    </div>
    <div class="controls half">
      <input type="text" id="lastName" class="floatLabel" name="Last Name">
      <label for="lastName">Last Name</label>
    </div>
    <div class="controls full">
      <input type="email" id="email" class="floatLabel" name="email">
      <label for="email">Email</label>
    </div>
  </div>
  <!--  Details -->
  <div class="form-group">
    <h2 class="heading full">Details</h2>
    <div class="controls full">
      <input type="tel" id="cell" class="floatLabel" name="cell">
      <label for="cell">Celly</label>
    </div>
    <div class="controls full">
      <select class="floatLabel">
        <option value="blank"></option>
        <option value="Apple">Apple</option>
        <option value="Banana">Banana</option>
        <option value="Kiwi">Kiwi</option>
        <option value="Orange">Orange</option>
        <option value="Watermelon">Watermelon</option>
      </select>
      <label for="fruit">Favotire Fruit</label>
    </div>
  </div>
  <!--  More -->
  <div class="form-group">
    <h2 class="heading full">More!</h2>
    <div class="controls full">
      <textarea name="comments" class="floatLabel" id="comments"></textarea>
      <label for="comments">Comments</label>
      <button class="full">Submit</button>
    </div>
  </div>
</form>




              
            
!

CSS

              
                @import "compass/css3";

@import "compass/reset";
@import "compass/css3";

// Basic variables
//
$break-medium: 960px;

// Color Map
// 
$colors: (
  'green': (
  	mint: #e9fff2,
  	tint: #80d4a4,
  	base: #45ae72
  ),
  'blue': (
  	base: #46A8E3,
    tint: #7dc2eb,
    shade: #31759e
  ),
  'gray': (
  	base: #808184
  )
);

// Function to grab colors
//
@function color($color-name, $tone: base) {
    @return map-get(map-get($colors, $color-name), $tone);
}

// Border Box
//
*{
	@include box-sizing(border-box);
}

// Not a grid, but gives you the idea 
//
.full {
  width: 100%;
  float: left;
  padding: 1em;
}

.half {
  width: 50%;
  float: left;
  padding: 1em;
}

.third {
  width: 33.3%;
  float: left;
  padding: 1em;
}

// General stuff 
//
body {
	text-align: center;
	font-family: 'Lato', 'sans-serif';
	font-weight: 400;
}

h2 {
  font-family: "Fjalla One";
}

a {
  text-decoration: none;
}

header {
  background: color("green", "tint");
  height: 200px;
  
  h2 {
    width: 100%;
    background: color("green");
    color: color("green", "tint");
    text-transform: uppercase;
    font-weight: 400;
    font-size: 1.2em;
    
    em {
      color: white;
    }
    
    a {
      color: white;
    }
  }
  
  .icon {
    font-family: "Fjalla One";
    font-size: 5em;
    font-weight: 700;
    padding: 0.5em;
    color: color("green")
  }
}

// Meat and potatoes
//
form{
	padding: 4em 20%; // blaze it!
  width: 80%;
    @media (max-width: $break-medium) { width: 100%; padding: 2em 10%; }
  margin: 0 auto;
}

h2.heading{
	font-size: 18px;
	text-transform: uppercase;
	font-weight: 300;
	text-align: left;
	color: color("green");
	border-bottom: 1px dashed color("green", "tint");
	padding: 1em;
	margin-bottom: 20px;
}

.controls{
	text-align: left;
	position: relative;
	input[type="text"],
	input[type="email"],
	input[type="tel"],
	textarea,
	button,
	select{
		padding: 12px;
		font-size: 14px;
		border: 2px solid color("gray");
		width: 100%;
		color: #888;
		font-family: 'Lato', 'sans-serif';
		font-size: 16px;
		@include border-radius(4px);
		@include transition(all .2s);

		&:focus, &:hover{
			outline: none;
			border-color: color('green');
			background: color('green', 'mint');
      
			+ label{
				color: color('green');
        cursor: text;
			}
		}
	}
  
	select{
		@include appearance(none);
		cursor: pointer;
	}
  
	label{
		position: absolute;
		left: 20px;
		top: 28px;
		color: #999;
		font-size: 16px;
		display: inline-block;
		padding: 4px 10px;
		font-weight: 700;
		// @include transition(color .3s, top .3s, background-color .8s);
    transition: color 0.3s, top 0.2s, font-size 0.2s;
    
		&.active{
			top: -10px;
      left: 16px;
			color: #555;
      font-style: oblique;
      font-size: 0.8em;
		}
	}
	textarea{
		resize: none;
		height: 200px;
	}
	button{
		cursor: pointer;
		background-color: color("blue");
		border: none;
		color: #fff;
		padding: 12px 0;
    margin: 1em 0;
		&:hover{
			background-color: color("blue", "tint");
		}
	}
}

              
            
!

JS

              
                // Added input value check on postback/load, removed floatLabel class from select input. Modified the scss, added color map.

(function($){
	function floatLabel(inputType){
		$(inputType).each(function(){
			var $this = $(this);
			var text_value = $(this).val();

			// on focus add class "active" to label
			$this.focus(function(){
				$this.next().addClass("active");
			});

			// on blur check field and remove class if needed
			$this.blur(function(){
				if($this.val() === '' || $this.val() === 'blank'){
					$this.next().removeClass();
					}
			});
					
			// Check input values on postback and add class "active" if value exists
			if(text_value!=''){
				$this.next().addClass("active");
				}
			});
    
    	// Automatically remove floatLabel class from select input on load
    	$( "select" ).next().removeClass();
	}
	// Add a class of "floatLabel" to the input field
	floatLabel(".floatLabel");
})(jQuery);
              
            
!
999px

Console