cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <section data-ng-controller="FlexboxCtrl as $ctrl" class="container-fluid">
  <header class="m-header text-center">
    <h2>Children - <code>flex-shrink</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-shrink: {{elem.shrink}};
                  -ms-flex-shrink: {{elem.shrink}};
                  flex-shrink: {{elem.shrink}};
                  
                  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-shrink
      <input type="number" min="0" class="form-control inpu-sm" ng-model="elem.shrink">
    </label>
    <hr>
    <button class="btn btn-danger btn-block" ng-click="$ctrl.removeElement($index)"><i class="glyphicon glyphicon-trash"></i></button>
  </div>
</script>
            
          
!
            
              $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: nowrap;
  
  
  .element {
    color: white;
    text-align: center;
    flex-basis: auto;
    width: calc(33.33% - 30px);
    flex-grow: 0;
    &: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;
    }
  }
}
            
          
!
            
              (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(),
      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 = '500px';
      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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console