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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div class="container" ng-app="myApp" ng-controller="mainCtrl">
  
  <div class="card">
    
    <h2>Checkboxes and removable labels</h2>
  
    <ul class="clearfix">
        <li ng-repeat="friend in friends">
          <div class="checkbox">
            <input type="checkbox" ng-model="friend.checked" ng-click="selectFriends(friend.name)" id="{{friend.id}}">
            <label for="{{friend.id}}">{{friend.name}}</label>
          </div>
        </li>
     </ul>
    
     <span ng-repeat="item in selection" ng-click="deselectFriend(item)" class="label label-success">{{item}} <i class="glyphicon glyphicon-remove"></i></span>
  </div>
</div>


            
          
!

CSS

            
              @import "compass";

// variables
$input-border: #D8D8D8;
$input-color: #999;

.container {
  padding: 40px 0;
}

// --------------------------------------------------
// Checkboxes from: https://github.com/flatlogic/awesome-bootstrap-checkbox
// I made some changes
// --------------------------------------------------
.checkbox{
  padding-left: 20px;

  label{
    display: inline-block;
    vertical-align: middle;
    position: relative;
    padding-left: 5px;

    &::before{
      content: "";
      display: inline-block;
      position: absolute;
      width: 17px;
      height: 17px;
      left: 0;
      margin-left: -20px;
      border: 1px solid $input-border;
      border-radius: 3px;
      background-color: #fff;
    }

    &::after{
      display: inline-block;
      position: absolute;
      width: 16px;
      height: 16px;
      left: 0;
      top: 0;
      margin-left: -20px;
      padding-left: 3px;
      padding-top: 1px;
      font-size: 11px;
      color: $input-color;
    }
  }
  
  input[type="checkbox"],
  input[type="radio"] {
    opacity: 0;
    z-index: 1;

  }

  &.checkbox-circle label::before{
    border-radius: 50%;
  }

  &.checkbox-inline{
    margin-top: 0;
  }
  
  input[type=checkbox]:checked + label:after {
      font-family: 'Glyphicons Halflings';
      content: "\e013";
  }
    label:after {
      padding-left: 4px;
      padding-top: 2px;
      font-size: 9px;
  }
}
// --------------------------------------------------
// Main 
// --------------------------------------------------
body {
  background: #eee;
  color: #999;
}
.card {
  background: #fff;
  padding: 20px 20px 40px;
  border-radius: 3px;
}
ul {
  margin: 0;
  padding-bottom: 10px;
}
.label {
  padding: 10px 20px;
  margin-right: 10px;
  cursor: pointer;
}

            
          
!

JS

            
              /* NOTE
if you don't what to use angular and arrays you can see this html and css "only" solution:
https://codepen.io/ryandunn/pen/YyMXjo
*/
var myApp = angular.module('myApp', []);

myApp.controller("mainCtrl", function($scope, $filter) {
  $scope.friends =
     [
      {
        "id": 0,
        "name": "Bell Parker"
      },
      {
        "id": 1,
        "name": "Heath Ryan"
      },
      {
        "id": 2,
        "name": "Burgess Doyle"
      }
    ];
  
  $scope.selection = []
    
  $scope.selectFriends = function (name) {
        
   
    var idx = $scope.selection.indexOf(name);
      
      // is currently selected
      if (idx > -1) {
        $scope.selection.splice(idx, 1);
      }
      
      // is newly selected
      else {
        $scope.selection.push(name);
 
      }
    
  }
  
  $scope.deselectFriend = function (name) {
 
    $scope.button = name;
    
    angular.forEach($scope.friends, function(item) {
      
      if ($scope.button == item.name) {
        item.checked = false;
      }
     
    });
    
    
    var idx = $scope.selection.indexOf(name);
      
      // is currently selected
      if (idx > -1) {
        $scope.selection.splice(idx, 1);
      }
      
  }
  
}); 
            
          
!
999px

Console