cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-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.

            
              <!-- tell angular this is flexboxDemoApp -->
<html lang="en" ng-app="flexboxDemoApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Игровая площадка Flexbox из CSS3  </title>
    <!-- Angulars Material CSS -->
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular-material.min.css">
    <!-- include our compiled CSS -->
    <link href="css/style.css" rel="stylesheet">
  </head>
  <!-- this will be the only controller AppCtrl -->
  <body ng-controller="AppCtrl">
    <!-- Here's the main container -->
    <md-content class="md-padding">
      <div layout-gt-md="row" layout="column">
        <div flex-gt-md="66" flex="100" class="right-padding">
          <h3>Ширина дочерних элементов</h3>
          <div layout="row" layout-align="center center" class="code">
            <div flex="15">width: {{children_width}}%</div>
            <md-slider flex min="0" max="100" ng-model="children_width" aria-label="width"></md-slider>
          </div>

          <md-divider></md-divider>

          <h3>Свойства родительского flex-элемента &ndash; <span class="highlight">flex-контейнер</span></h3>
          <div layout="column" layout-gt-md="row" class="code">
            <div layout="row">
              <div flex>
                <strong>flex-direction</strong>
                <md-radio-group ng-model="parent.flexDirection">
                  <md-radio-button value="row" class="highlight">row</md-radio-button>
                  <md-radio-button value="row-reverse">row-reverse</md-radio-button>
                  <md-radio-button value="column">column</md-radio-button>
                  <md-radio-button value="column-reverse">column-reverse</md-radio-button>
                </md-radio-group>
              </div>
              
              <div flex>
                <strong>flex-wrap</strong>
                <md-radio-group ng-model="parent.flexWrap">
                  <md-radio-button value="nowrap" class="highlight">nowrap</md-radio-button>
                  <md-radio-button value="wrap">wrap</md-radio-button>
                  <md-radio-button value="wrap-reverse">wrap-reverse</md-radio-button>
                </md-radio-group>
              </div>
            </div>

            <div layout="row">
              <div flex>
                <strong>justify-content</strong>
                <md-radio-group ng-model="parent.justifyContent">
                  <md-radio-button value="flex-start" class="highlight">flex-start</md-radio-button>
                  <md-radio-button value="flex-end">flex-end</md-radio-button>
                  <md-radio-button value="center">center</md-radio-button>
                  <md-radio-button value="space-between">space-between</md-radio-button>
                  <md-radio-button value="space-around">space-around</md-radio-button>
                </md-radio-group>
              </div>

              <div flex>
                <strong>align-items</strong>
                <md-radio-group ng-model="parent.alignItems">
                  <md-radio-button value="stretch" class="highlight">stretch</md-radio-button>
                  <md-radio-button value="flex-start">flex-start</md-radio-button>
                  <md-radio-button value="flex-end">flex-end</md-radio-button>
                  <md-radio-button value="center">center</md-radio-button>
                  <md-radio-button value="baseline">baseline</md-radio-button>
                </md-radio-group>
              </div>
            </div>

            <div layout="row">
              <div flex>
                <strong>align-content</strong>
                <md-radio-group ng-model="parent.alignContent">
                  <md-radio-button value="stretch" class="highlight">stretch</md-radio-button>
                  <md-radio-button value="flex-start">flex-start</md-radio-button>
                  <md-radio-button value="flex-end">flex-end</md-radio-button>
                  <md-radio-button value="center">center</md-radio-button>
                  <md-radio-button value="space-between">space-between</md-radio-button>
                  <md-radio-button value="space-around">space-around</md-radio-button>
                </md-radio-group>
              </div>
            </div>
          </div>

          <small>* Значение свойства по умолчанию <span class="highlight">подсвечены</span>.</small>

          <md-divider></md-divider>

          <h3>Свойства дочерних элементов &ndash; <span class="highlight">flex-элементы</span></h3>

          <div>
            <p>Свойства дочерних flex-элементов могут быть применены на дочернем уровне, раздельно для каждого элемента. Смотрите раздел с результатами и изменяйте какие-нибудь из их свойств. Наведите указатель мыши или коснитесь поля, чтобы увидеть название свойства.</p>
          </div>

          <md-divider hide show-sm show-md></md-divider>
        </div>

        <div flex>
          <h3 class="pull-left">Результат</h3>
          <p class="pull-right">
            <md-button class="md-accent md-raised" ng-click="addChild()">Добавить дочерний элемент</md-button>
          </p>

          <div class="clearfix"></div>

          <div
            class="flexbox-parent" 
            ng-attr-style="
              -webkit-flex-direction:  {{parent.flexDirection}};
              flex-direction:          {{parent.flexDirection}};

              -webkit-flex-wrap:       {{parent.flexWrap}};
              flex-wrap:               {{parent.flexWrap}};

              -webkit-justify-content: {{parent.justifyContent}};
              justify-content:         {{parent.justifyContent}};

              -webkit-align-items:     {{parent.alignItems}};
              align-items:             {{parent.alignItems}};

              -webkit-align-content:   {{parent.alignContent}};
              align-content:           {{parent.alignContent}};
              "
          >
            <div 
              class="code md-whiteframe-z1"
              ng-repeat="child in children"
              ng-attr-style="
                width:               {{children_width}}%;

                -webkit-order:       {{child.order}};
                order:               {{child.order}};

                -webkit-flex-grow:   {{child.flexGrow}};
                flex-grow:           {{child.flexGrow}};

                -webkit-flex-shrink: {{child.flexShrink}};
                flex-shrink:         {{child.flexShrink}};

                -webkit-flex-basis:  {{child.flexBasis}};
                flex-basis:          {{child.flexBasis}};

                -webkit-align-self:  {{child.alignSelf}};
                align-self:          {{child.alignSelf}};

              "
            >
              <div class="clearfix">
                <span class="child-number" aria-label="Number">{{$index + 1}}</span>
                <span class="remove-child pull-right" ng-click="removeChild($index)" title="Remove">
                  &#x2716;
                </span>
              </div>

              <div class="child-controls">
                <md-input-container>
                  <md-tooltip md-direction="top">order</md-tooltip>
                  <input type="number" ng-model="children[$index].order">
                </md-input-container>

                <md-input-container>
                  <md-tooltip md-direction="top">flex-grow</md-tooltip>
                  <input type="number" ng-model="children[$index].flexGrow">
                </md-input-container>

                <md-input-container>
                  <md-tooltip md-direction="top">flex-shrink</md-tooltip>
                  <input type="number" ng-model="children[$index].flexShrink">
                </md-input-container>

                <md-input-container>
                  <md-tooltip md-direction="top">flex-basis</md-tooltip>
                  <input type="text" ng-model="children[$index].flexBasis">
                </md-input-container>

                <md-input-container>
                  <md-tooltip md-direction="top">align-self</md-tooltip>
                  <md-select ng-model="children[$index].alignSelf">
                    <md-option ng-value="value" ng-repeat="value in ['auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch']">{{value}}</md-option>
                  </md-select>
                </md-input-container>
              </div>
                
            </div>
          </div>
        </div>
      </div>
    </md-content>
    
    <!-- AngularJS -->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-animate.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-aria.min.js"></script>

    <!-- Angular Material JavaScript -->
    <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular-material.min.js"></script>

    <!-- App.js -->
    <script src="js/app.js"></script>
  </body>
</html>

            
          
!
            
              @import "compass/css3";

@import "compass";

// Flex container
.flexbox-parent {
  @include display-flex;
  background: #FFD54F;
  overflow: hidden;
  width: 100%;
  padding: 3px;
  min-height: 550px;
  max-height: 1000px;

  // Flex items
  > div {
    display: inline-block;
    background: white;
    overflow: hidden;
    margin: 3px;
    padding: 5px;

    .child-controls {
      margin-top: 7px;
    }
  }
}

.child-number {
  display: block;
  width: 22px;
  height: 22px;
  background: #FFB300;
  color: white;
  font-size: 14px;
  font-weight: bold;
  padding-top: 3px;
  text-align: center;
  @include border-radius(50%);
  float: left;
}

.code {
  font-family: Consolas, "Courier New", Monospace;
  font-size: 15px;
}

.remove-child {
  background: transparent;
  color: #FF6F00;
  font-size: 14px;
  cursor: pointer;
}

.highlight {
  color: #FF8F00;
}

.pull-left {
  float: left;
}

.pull-right {
  float: right;
}

.clearfix {
  &:after {
    content: '';
    display: block;
    clear: both;
  }
}

.right-padding {
  padding-right: 15px;
}

h3 {
  margin: 0 0 10px 0 !important;
}

p {
  margin: 0 0 10px 0 !important;
  line-height: 1.4em !important;
}

md-input-container {
  padding: 0 0 5px 0 !important;

  .md-input {
    padding: 0 !important;
    line-height: 1em !important;
  }
}

md-select {
  margin-top: 0 !important;

  .md-select-label {
    padding-top: 2px !important;
    padding-bottom: 4px !important;
  }
}

md-radio-button {
  margin: 5px 10px !important;
}

md-divider {
  margin: 10px 0 !important;
}

            
          
!
            
              // Declare the flexboxDemoApp module and its dependency 'ngMaterial'
var app = angular.module('flexboxDemoApp', ['ngMaterial']);
// Declare the AppCtrl controller
app
.config(['$mdThemingProvider', function ($mdThemingProvider) {
  $mdThemingProvider
    .theme('default')
    .accentPalette('amber', {
      default: '700'
    });
}])
.controller('AppCtrl', ['$scope', function ($scope) {
  $scope.parent = {
    flexDirection:  'row',
    flexWrap:       'nowrap',
    justifyContent: 'flex-start',
    alignItems:     'stretch',
    alignContent:   'stretch'
  };

  $scope.children_width = 12; // %

  $scope.children  = [];

  var addChild = function (order, flexGrow, flexShrink, flexBasis, alignSelf) {
    $scope.children.push({
      order:      order      || 0,
      flexGrow:   flexGrow   || 0,
      flexShrink: flexShrink || 1,
      flexBasis:  flexBasis  || 'auto',
      alignSelf:  alignSelf  || 'auto'
    });
  };
  var removeChild = function (index) {
    $scope.children.splice(index, 1);
  };

  $scope.addChild    = addChild;
  $scope.removeChild = removeChild;

  for (var i = 0; i < 5; i++) {
    addChild();
  }
    
}]);

            
          
!
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