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
  .mondrian
    .mondrian__block(v-for="block in blocks", :data-row-span="block.rowSpan", :data-col-span="block.colSpan", :data-color-index="block.colorIndex")
  button.generate-button(v-on:click='regenerate') Regenerate
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Lato:300,900')

$mondrian-black = rgb(7, 9, 8)
$mondrian-yellow = rgb(248, 217, 45)
$mondrian-white = rgb(242, 245, 241)
$mondrian-blue = rgb(11, 84, 164)
$mondrian-red = rgb(214, 0, 20)

$colors = $mondrian-white $mondrian-yellow $mondrian-white $mondrian-blue $mondrian-white $mondrian-red

$blockSize = 50px
$height = 6 * $blockSize
$width = 5 * $blockSize

*
  box-sizing border-box
  animation  fadeIn .5s

body
html
  background-color #fff
  display grid
  align-items center
  justify-content center
  font-family 'Lato', sans-serif
  text-align       center
  padding 20px
  min-height 100vh
  width 100vw

.mondrian
  background-color $mondrian-black
  border 10px solid $mondrian-black
  box-shadow 5px 10px 10px #aaa
  display grid
  grid-auto-columns $blockSize
  grid-auto-flow dense
  grid-auto-rows $blockSize
  grid-gap 10px
  grid-template-columns repeat(auto-fit, $blockSize)
  grid-template-rows repeat(auto-fit, $blockSize)
  height $height
  overflow hidden
  width $width

  &__block
    animation scaleIn .25s ease 0s
    background-color $mondrian-white

    for $block in (1..10)
      &:nth-child({$block})
        animation-delay $block * 0.15s
        background-color $color
        transform scale(0)
        animation-fill-mode forwards

    for $modifier in (1..3)
      &[data-row-span=\"{$modifier}\"]
        grid-row span $modifier
      &[data-col-span=\"{$modifier}\"]
        grid-column span $modifier

    for $colorIndex in (1..6)
      &[data-color-index=\"{$colorIndex}\"]
        background-color $colors[$colorIndex - 1]

.generate-button
  cursor pointer
  padding 4px 12px
  border-radius 4px
  font-family 'Lato', sans-serif
  margin-top 30px
  background-color #fff

  &:hover
    background-color darken(#fff, 10%)
  &:active
    background-color darken(#fff, 20%)



@keyframes scaleIn
  from
    transform scale(0)
  to
    transform scale(1)

@keyframes fadeIn
  from
    opacity 0
  to
    opacity 1
              
            
!

JS

              
                const app = new Vue({
  el: '#app',
  data: {
    blocks: [],
  },
  methods: {
    generateBlocks: function() {
      for (let i = 0; i < 10; i++) {
        this.blocks.push({
          colSpan: Math.floor(Math.random() * 3 + 1),
          rowSpan: Math.floor(Math.random() * 3 + 1),
          colorIndex: Math.floor(Math.random() * 6 + 1),
        })
      }
    },
    regenerate: function() {
      this.blocks = []
      setTimeout(() => this.generateBlocks(), 0)
    },
  },
  mounted: function () {
    this.generateBlocks()
  }
})

              
            
!
999px

Console