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 class="container" ng-controller="FlexboxCtrl as $ctrl">
  <h2 class="text-center">Wrapper <code>justify-content: <select class="inpu-sm" ng-options="option as option.name for option in $ctrl.justifyOptions track by option.id" ng-model="$ctrl.justifyContent"></select> ;</code></h2>
  <p class="text-center">Try this sample in full view and add at least two more elements for "space-around" and "space-between" differences!</p>
  <ul class="c-blurbs list-unstyled justify-content__{{$ctrl.justifyContent.name}}">
    <li class="c-blurbs__item" ng-repeat="blurb in $ctrl.blurbs track by $index">
      <figure>
        <img class="c-blurbs__item__img" src="https://bs-uploads.toptal.io/blackfish-uploads/components/branding_page/logo_section/row/main/content/image_file/image/648622/logo-b4cc4f553c576cb4465dde0e7f578f63.svg" alt="Blurb subject">
        <figcaption>
          <h4>Some blurb element</h4>
          <p>Lorem ipsum dolor sit amet.</p>
          <button class="btn btn-danger btn-block" ng-click="$ctrl.removeElement($index)"><i class="glyphicon glyphicon-trash"></i></button>
        </figcaption>
      </figure>
    </li>
  </ul>
  <button class="btn btn-success btn-block" ng-click="$ctrl.addElement()"><i class="glyphicon glyphicon-plus"></i></button>
</section>
              
            
!

CSS

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

.c-blurbs{
  display: flex;
  flex-wrap: wrap;
  text-align: center;
  
  &.justify-content{
    &__flex-start{justify-content: flex-start;}
    &__flex-end{justify-content: flex-end;}
    &__center{justify-content: center;}
    &__space-around{justify-content: space-around;}
    &__space-between{justify-content: space-between;}
  }
  
  &__item{
    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: auto;
    
    width: calc(33.33% - 60px); // Due to issues with IE and box-sizing: border-box this is the best workaround
    padding: 30px;
    box-sizing: content-box;
    position: relative;
    
    &__img{
      max-width: 120px;
    }
    
    figure{
      margin: 0;
    }
    
    .btn-danger{
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      opacity: 0;
      transition: all 200ms;
    }
    
    &:hover{
      .btn-danger{
        opacity: 1;
      } 
    }
    
    @media only screen and (max-width: 768px) and (min-width: 641px){
      width: calc(50% - 60px);
    }
    
    @media only screen and (max-width: 640px){
      width: calc(100% - 60px);
    }
  }
}
              
            
!

JS

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

  // Dependencies injections
  //FlexboxCtrl.$inject = [];

  // Flexbox controller (hoists)
  function FlexboxCtrl(){
    var $ctrl = this;
    
    $ctrl.justifyOptions = [
      {id: 1, name: "flex-start"},
      {id: 2, name: "flex-end"},
      {id: 3, name: "center"},
      {id: 4, name: "space-around"},
      {id: 5, name: "space-between"}
    ];
    
    $ctrl.justifyContent = $ctrl.justifyOptions[0];
    
    $ctrl.blurbs = [
      '','','','',''
    ]    
    
    $ctrl.removeElement = removeElement;
    $ctrl.addElement = addElement;
    
    function removeElement(index){
      $ctrl.blurbs.splice(index, 1);
    }
    
    function addElement(){
      $ctrl.blurbs.push('');
    }
  }
  
  // Run app
  angular.bootstrap(document, ['flexbox']);
})(angular)



              
            
!
999px

Console