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

              
                #app
  h1 Flexbox Visual Playground
  .flexboxes.container-fluid(:style="getStyle", :class="direction")
    .box 1
    .box 2
    .box 3
    .box 4
    .box 5
    .axis.main 
      label 主軸線 (justify)
    .axis.sub 
      label 副軸線 (align)
  .settings.container-fluid
    br
    .form-group.row
      .col-sm-3
        label 方向(flex-direction)
      .col-sm-9
        .btn-group
          button.btn.btn-secondary(
            v-for="d in values.direction",
            @click="direction=d", 
            :class="{active: direction==d}") {{d}}
    .form-group.row
      .col-sm-3
        label 主軸分布(justify-content)
      .col-sm-9
        .btn-group
          button.btn.btn-secondary(
            v-for="d in values.justify",
            @click="justify=d",
            :class="{active: justify==d,'btn-warning': d.indexOf('space')!=-1}") {{d}}
    .form-group.row
      .col-sm-3
        label 副軸分布(align-items)
      .col-sm-9
        .btn-group
          button.btn.btn-secondary(
            v-for="d in values.align",
            @click="align=d", 
            :class="{active: align==d,'btn-warning': d.indexOf('space')!=-1}") {{d}}

              
            
!

CSS

              
                *
  // transition: 0.5s
=flexCenter
  display: flex
  justify-content: center
  align-items: center
html,body
  width: 100%
  height: 100%
  margin: 0
  // background-color: #111
  +flexCenter
  
body
  padding-top: 100px
.flexboxes
  border: solid 10px #333
  position: relative
  display: flex
  // width: 800px
  height: 500px
  margin: 50px
  padding: 0
  &.column,&.column-reverse
    .axis.main
      width: 0px
      height: 100%
      label
        top: -50px
        right: initial
    .axis.sub
      width: 100%
      height: 0px
      label
        right: -120px
        top: initial

  
.box
  width: 15%
  height: 15%
  background-color: #fff
  font-size: 40px
  
.axis
  position: absolute  
  left: 50%
  top: 50%
  transform: translate(-50%,-50%)
  text-align: center
  label
    position: absolute
    right: -120px
    white-space: nowrap
.axis.main
  width: 100%
  height: 0px
  border: solid 2px red
  color: red
.axis.sub
  width: 0px
  height: 100%
  border: solid 2px MediumBlue  
  color: MediumBlue 
  label
    position: absolute
    top: -50px

  
  
.box
  display: flex
  justify-content: center
  align-items: center
  background-color: #333
  border: solid 2px #666
  color: #666
  position: relative
  z-index: 100
  
  @for $i from 1 through 5
    &:nth-child(#{$i})
      background-color: rgba(white,$i*0.15+0.2)
  
.settings
  background-color: #fff
              
            
!

JS

              
                var vm = new Vue({
  el: "#app",
  data: {
    direction: "row",
    justify: "center",
    align: "center",
    values: {
      direction: ["row","column","row-reverse","column-reverse"],
      justify: ["flex-start","center","flex-end","space-around","space-between","space-evenly"],
      
      align: ["flex-start","center","flex-end","space-around","space-between","space-evenly"]
    }
  },
  computed: {
    getStyle(){
      return {
        "flex-direction": this.direction,
        "justify-content": this.justify,
        "align-items": this.align,
        
      }
    }
  }
})
              
            
!
999px

Console