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

              
                <form data-ng-app="placeholder" class="placeholder">
  <div class="form-control">
    <select name="registered_nurse" data-ng-model="registered_nurse" placeholder="Are you awesome?">
      <option value=""></option>
      <option value="N">No</option>
      <option value="Y">Yes</option>
    </select>
  </div>
  <div class="form-control">
    <input type="tel" data-ng-min-length="5" maxlength="5" name="zipcode" placeholder="Zip Code" data-ng-model="zipcode">
  </div>
</form>
              
            
!

CSS

              
                $white: #fff;
$color-ccn-gold: #f5b611;
$color-ccn-gray: #72635d;

/* ADDS A BROWSER PREFIX TO THE PROPERTY */
@mixin css3-prefix($property, $value) {
  -webkit-#{$property}: #{$value};
  -khtml-#{$property}: #{$value};
  -moz-#{$property}: #{$value};
  -ms-#{$property}: #{$value};
  -o-#{$property}: #{$value};
  #{$property}: #{$value};
}

.form-control {
  padding: 0 5px 5px 0;

  input, select {
    @include css3-prefix('border-radius', 4px);
    background-color: $white;
    width: 100%;
    height: 40px;
    border: 1px solid $color-ccn-gray;
    padding: 4px;
    font-size: 0.8em;
    color: $color-ccn-gray;
  }
}

.placeholder {
	.form-control {
		position: relative;
	}

	.form-control input[type="text"],
	.form-control input[type="number"],
	.form-control input[type="email"],
	.form-control input[type="tel"],
	.form-control input[type="password"] {
	  -webkit-appearance: none;
	  -moz-appearance: none;
	  appearance: none;

	  &::-webkit-input-placeholder {
	    color: transparent;
	  }
	  &:-moz-placeholder {
	    color: transparent;
	  }
	  &::-moz-placeholder {
	    color: transparent;
	  }
	  &:-ms-input-placeholder {
	    color: transparent;
	  }
	}

	.placeholder-text {
	  font-family: sans-serif;
	  cursor: text;
	  color: #999;
	  left: 7px;
	  position: absolute;
	  top: 16px;
	  @include css3-prefix('transition', all 0.2s linear);

	  .disabled & {
	    color: #aaa;
	  }
	}

	.float-label {
	  font-family: sans-serif;
	  font-size: 0.6em;
	  left: 7px;
	  position: absolute;
	  top: 2px;
	}

	.float-label.ng-hide-add.ng-hide-add-active,
	.float-label.ng-hide-remove.ng-hide-remove-active {
	  @include css3-prefix('opacity', 1);
	  @include css3-prefix('transition', all 0.2s linear);
	}

	// Important is being used to accommodate having to use Angular 1.2
	.float-label.ng-hide {
	  @include css3-prefix('opacity', 0);
	  z-index: -1;
	}

	.placeholder-text.ng-hide-add.ng-hide-add-active,
	.placeholder-text.ng-hide-remove.ng-hide-remove-active {
	  font-size: 1em;
	}

	// Important is being used to accommodate having to use Angular 1.2
	.placeholder-text.ng-hide {
	  font-size: 0.7em;
	  @include css3-prefix('opacity', 0);
	  z-index: -1;
	}
}
              
            
!

JS

              
                "use strict"

angular.module('placeholder', [])

.directive('placeholder', ['$compile', '$timeout', function($compile, $timeout) {
  var tmpl = '<div data-ng-click="focus()"><div class="placeholder-text" data-ng-hide="hasFocus" data-ng-bind="placeholder"></div>' +
  '<div class="float-label" data-ng-show="hasFocus" data-ng-bind="placeholder"></div></div>';

  var linkFn = function(scope, elem, attrs, ctrl) {
    // Add the template and compile it into the scope
    // We can't do this in the compile function as it would be
    // outside the element and not compiled into the scope
    elem.after($compile(tmpl)(scope));

    elem.on('focus', function() {
      // We use $timeout here to schedule the property update to be processed
      // in the next $digest.  If we used $apply we'd potentially get an "already running" error
      // as the focus event could come from a click or a tab
      $timeout(function() {
        scope.hasFocus = true;
      });
    }).on('blur', function() {
      // This line deals with chrome not returning non-numeric values
      // with val() when they're entered into an input of type number
      elem.val(elem.val());
      // Here we need to call apply to update the property
      // This won't ever be called while a digest is already running
      scope.$apply(function() {
        if (!elem.val()) scope.hasFocus = false;
      });
    });

    // Respond to view value changes
    ctrl.$viewChangeListeners.push(function() {
      scope.hasFocus = ctrl.$viewValue ? true : false;
    });

    scope.$watch(function() {
      return elem.is(':disabled');
    }, function(disabled) {
      scope.hasFocus = ctrl.$viewValue ? true : false;
    });

    // Focuses on field when the placeholder is clicked
    scope.focus = function() {
      elem[0].focus();
      scope.hasFocus = true;
    };
  };

  return {
    restrict: 'A',
    scope: {
      placeholder: '@'
    },
    require: 'ngModel',
    link: linkFn
  };
}]);

              
            
!
999px

Console