scss 浮动标签pattern--角JS.markdown

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss 浮动标签pattern--角JS.markdown相关的知识,希望对你有一定的参考价值。

Floating label pattern — Angular JS
-----------------------------------
Angular JS demo of a floating label. Based on floating label pattern by Matt D. Smith 

Forked from [Fedor Troitsky](http://codepen.io/ftroitsky/)'s Pen [Floating label pattern — Angular JS](http://codepen.io/ftroitsky/pen/xwLcv/).

A [Pen](http://codepen.io/jetviper21/pen/fqaGy) by [Scott Davis](http://codepen.io/jetviper21) on [CodePen](http://codepen.io/).

[License](http://codepen.io/jetviper21/pen/fqaGy/license).
<div ng-app='myApp' class="container">
    <magic-field>
      <label ng-show="showLabel" class="show-hide">Better field </label>
      <input type='text' placeholder="Better field" />
   </magic-field>
    <magic-field>
      <label ng-show="showLabel" class="show-hide">Better Text Area </label>
      <textarea type='text' placeholder="Better Text Area"></textarea>
   </magic-field>
</div>
<img src="https://dl.dropboxusercontent.com/u/177158/magic.gif"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular-animate.js"></script>
var myApp = angular.module('myApp', ['ngAnimate']);
myApp.directive('magicField', function($compile) {
  return {
    scope: {},
    template: '<div class="field" ></div>',
    transclude : true,
    replace : true,
    restrict : 'E',
    controller: function($scope, $element) {
      $scope.showLabel = false;
    },
    link: function(scope, element, attrs, ctrl, transclude) {
      transclude(scope, function(clone, scope) {
        element.append(clone);
      });
      var input = element.find('input')[0] || element.find('textarea')[0] || element.find('select')[0];
      input = angular.element(input);
      input.on('keyup', function() {
        if(input.val().length > 0) {
          scope.showLabel = true;
        } else {
          scope.showLabel = false;
        }
        scope.$apply();
      });
    }
  }
});
@import "compass/css3";
$focus-border-color: #428bca;

.container {
  padding-top: 4em;
}
.field {
  .show-hide.ng-hide-add, .show-hide.ng-hide-remove {
      -webkit-transition:all linear 0.2s;
      -moz-transition:all linear 0.2s;
      transition:all linear 0.2s;
      display:block!important;
      position: absolute;
  }

  .show-hide.ng-hide-add.ng-hide-add-active,
  .show-hide.ng-hide-remove {
      top: -8px;
      display:block!important;
      position: absolute;
      opacity: 0;

  }

  .show-hide.ng-hide-add,
  .show-hide.ng-hide-remove.ng-hide-remove-active {
      top:-10px;
      opacity: 1;
      display:block!important;
      position: absolute;
  }
  %input-area {
    &:focus {
      border-color : $focus-border-color;
    }
    border: 0;
    padding: 7px 0.5em!important;
    outline: none;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    box-shadow: none !important;
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    border-radius: 0;;
    border: 2px solid #555555;
    min-width: 300px;
    margin-top: 0px;
    font-weight: bold;
    font-size : 16px;
    color : #555;
  }
}

.field {
    position: relative;
    margin-bottom: 1em;
    padding-bottom: 1em;
}
.field label {
    position: absolute;
    top: -10px;
    left: 0.3em;
    padding-left:.3em;
    padding-right:.3em;
    color: $focus-border-color;
    font-size: 1em;
    background-color : white;
    font-weight : bold;
}
.field input[type=text], input[type=tel], input[type=search], input[type=email] {
  @extend %input-area;
}

.field > textarea {
  @extend %input-area;
}

以上是关于scss 浮动标签pattern--角JS.markdown的主要内容,如果未能解决你的问题,请参考以下文章

Vue/Tailwind 中的浮动标签

scss #todoapp-角NGRX

角材料芯片占位符浮动而不是在末端附着

scss 传统的sass网格系统没有flexbox,但也没有使用浮动。为具有IE9支持的项目创建。

带有自定义组件的角包裹角材料标签组件

scss 标签dot.scss