Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <section data-ng-controller="FlexboxCtrl as $ctrl" class="container-fluid">
  <header class="m-header text-center">
    <h2>Children - <code>flex-grow</code></h2>
    <p class="h3">Edit or remove the elements by clicking them or add a few more bellow the wrapper</p>
  </header>
  
  <!-- Wrapper -->
  <div class="col-md-offset-3 col-md-6 col-xs-12">   
    <ul class="sample-wrapper list-unstyled">
      <li ng-repeat="elem in $ctrl.elements track by $index"
           tabindex="0"
           class="element u-clickable" 
           style="
                  -webkit-flex-grow: {{elem.grow}};
                  -ms-flex-grow: {{elem.grow}};
                  flex-grow: {{elem.grow}};
                  
                  -webkit-flex-shrink: {{elem.shrink}};
                  -ms-flex-shrink: {{elem.shrink}};
                  flex-shrink: {{elem.shrink}};
                  
                  -webkit-flex-basis: {{elem.basis}};
                  -ms-flex-basis: {{elem.basis}};
                  flex-basis: {{elem.basis}};
                  
                  height: {{elem.height}};
                  
                  -webkit-order: {{elem.order}};
                  -ms-order: {{elem.order}};
                  order: {{elem.order}};
                  
                  -webkit-align-self: {{elem.alignSelf.name}};
                  -ms-align-self: {{elem.alignSelf.name}};
                  align-self: {{elem.alignSelf.name}};
           "
           uib-popover-template="$ctrl.popover.templateUrl"
           popover-title="{{$ctrl.popover.title}}"
           popover-placement="auto"
           popover-trigger="'outsideClick'"
           ></li>
    </ul>
    <button class="btn btn-success btn-block" ng-click="$ctrl.addElement()" ng-show="$ctrl.elements.length < 10 || !!$ctrl.infiniteItems"><i class="glyphicon glyphicon-plus"></i></button>
    <div ng-show="$ctrl.elements.length >= 10 || !!$ctrl.infiniteItems" class="alert alert-warning alert-dismissible" role="alert">
      <p><strong>Ups!</strong> You have reached the limit of 10 elements.</p>
      <p ng-click="$ctrl.infiniteItems = !$ctrl.infiniteItems" class="u-clickable">
        <span class="u-checkbox" ng-class="{'active': $ctrl.infiniteItems}">
          <i class="fa fa-check"></i>
        </span>
        I don't care I want to add more
      </p>
    </div>

  </div>
</section>

<script type="text/ng-template" id="popover.html">
  <div class="form-group">
  	<label>
      flex-grow
      <input type="number" min="0" class="form-control inpu-sm" ng-model="elem.grow">
    </label>
    <hr>
    <button class="btn btn-danger btn-block" ng-click="$ctrl.removeElement($index)"><i class="glyphicon glyphicon-trash"></i></button>
  </div>
</script>
              
            
!

CSS

              
                $blue: #3863A0;
$green: #3DBE8B;

/**
 * Refactors
 */
.rzslider .rz-pointer {
  background-color: $blue;
  &:focus{
    outline: none;
    box-shadow: none;
    background-color: $green;
    &:after{
      background-color: $blue;
    }
  }
}
.rzslider .rz-selection {
  background-color: darken($green, 10%);
}

.btn-primary {
  background-color: $green!important;
  border-color: darken($green, 10%)!important;
  &.active{
    background-color: $blue!important;
    border-color: darken($blue, 10%)!important;
  }
}

.btn-success {
  background-color: $green!important;
  border-color: darken($green, 10%)!important;
  margin-bottom: 20px;
}

.popover{
  .form-group{
      padding: 10px;
      label{
        display: block;
      }
    }
}

/**
 * Utilities
 */
.u-clickable{
  cursor: pointer;
  user-select: none;
}
.u-checkbox{
  display: inline-block;
  width: 20px;
  height: 20px;
  border: solid 1px #a9a9a9;
  background-color: white;
  border-radius: 2px;
  text-align: center;
  margin-right: 10px;
  .fa{
    opacity: 0;
    color: $green;
    transition: all 400ms linear;
  }
  &.active{
    .fa{
      opacity: 1;
    }
  }
}


/**
 * Modules
 */
.m-header{
  margin-bottom: 30px;
}
.m-menu{
  li{
    border-bottom: solid 1px lightgray;
    padding-bottom: 20px;
  }
}

.sample-wrapper{
  border: dashed 4px #A9A9A9;
  transition: all 400ms linear;
  counter-reset: elements;
  margin-bottom: 20px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  
  
  .element {
    color: white;
    text-align: center;
    &:focus{
      box-shadow: 0 0 0px 4px white, 0 0 0px 8px orange;
      outline: none;
    }
    
    @for $i from 1 to 11{
      &:nth-of-type(#{$i}n){
        
        margin: 15px;
        @if $i < 6 {
          $darken: $i * 5% - 5;
          background: darken($blue, $darken);
        } @else {
          $j: $i - 5;
          $darken: $j * 5% - 5;
          background: darken($green, $darken);
        }
      }
    }
    &:before{
      counter-increment: elements;
      content: counter(elements);
      display:block;
      margin: 5px;
    }
  }
}
              
            
!

JS

              
                (function(angular){
  'use strict';
  
  // Define app and elements
  angular.module("flexbox", ['ngSanitize','ui.bootstrap'])
    // Flexbox controller (called from the component)
    .controller('FlexboxCtrl', FlexboxCtrl);

  // Dependencies injections
  FlexboxCtrl.$inject = ['$uibModal', '$document'];

  // Flexbox controller (hoists)
  function FlexboxCtrl($uibModal, $document){
    var $ctrl = this,
        Element = El;
    
    $ctrl.minHeight = 707;
    
    $ctrl.maxWidth = 1920;
    
    $ctrl.infiniteItems = false;
    
    /**
     * Wrapper config
     */
    
    // Display
    $ctrl.display = 'flex';    
    // Direction
    $ctrl.direction = 'row';    
    // Wrap
    $ctrl.wrap = 'nowrap';
    // Justify content
    $ctrl.justifyContent = 'flex-start';
    // Align items
    $ctrl.alignItems = 'stretch';
    // Align content
    $ctrl.alignContent = 'stretch';
    
    
    /**
     * Wrapper children (elements)
     */
    $ctrl.popover = {
      templateUrl: 'popover.html',
      title: 'Element config'
    };
    
    $ctrl.elements = [
      new Element(),
      new Element(),
      new Element()     
    ];
    
    $ctrl.removeElement = removeElement;
    $ctrl.addElement = addElement;
    $ctrl.editElement = editElement;
    
    function El (){
      this.alignOptions = [
        {id: 0, name: "none"},
        {id: 1, name: "flex-start"},
        {id: 2, name: "flex-end"},
        {id: 3, name: "center"},
        {id: 4, name: "stretch"},
        {id: 5, name: "baseline"}
      ];
      
      this.grow = 0;
      this.shrink = 1;
      this.basis = '100px';
      this.height = 'auto';
      this.order = 0;        
      this.alignSelf = this.alignOptions[0];
    }
    
    function removeElement(index){
      $ctrl.elements.splice(index, 1);
      console.log($ctrl.elements.length);
    }
    
    function addElement(){
      console.log($ctrl.elements);
      $ctrl.elements.push(new Element());
    }
    
    function editElement(el, index){      
      $uibModal.open({
        animation: true,
        templateUrl: 'modal.html',
        size: 'sm',
        controllerAs: '$ctrl',
        controller: function(){
          console.log(el);
        }
      });
    }
  
  }
  
  // Run app
  angular.bootstrap(document, ['flexbox']);
})(angular)



              
            
!
999px

Console