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.

            
              .panel
  fieldset
    legend justify-content
    select(name='jc')
      each val in ['stretch', 'start', 'end', 'flex-start', 'flex-end', 'left', 'right', 'center', 'space-between', 'space-around', 'space-evenly']
        option(value=''+val)
          =val
  fieldset
    legend align-content
    select(name='ac')
      each val in ['stretch', 'start', 'end', 'flex-start', 'flex-end', 'left', 'right', 'center', 'space-between', 'space-around', 'space-evenly']
        option(value=''+val)
          =val

.container#grid
  each val in ['Раз контент', 'Два контент', 'Три контент', 'Четыре контент', 'Контент справа налево','Еще контент']
    .item
      =val
    .helper
            
          
!
            
              
.container {
  width: 500px;
  height: 380px;
  border: 1px solid green;
}
#grid {
  display: grid;
  grid: repeat(2, auto) / repeat(3, auto);
}
#flex {
  display: flex;
  flex-flow: row wrap;
}
.item {
  background: rgba(255,160,160,.5);
  border: 1px solid rgba(255,0,0,.5);
}
#flex .item:nth-child(5), #grid .item:nth-child(9) {
  direction: rtl;
  background: rgba(160,255,160,.5);
  border: 1px solid rgba(0,255,0,.5);
}
.tb {
  writing-mode: tb-rl;
}
.helper {
  background: #ccc;
  justify-self: stretch;
  align-self: stretch;
  border: 1px solid #888;
  z-index: -1;
}
@for $i from 0 through 1 {
  @for $j from 0 through 2 {
    .item:nth-child(#{($i * 3 + $j) * 2 + 1}), .helper:nth-child(#{($i * 3 + $j) * 2 + 2}) {
      grid-row: #{$i + 1};
      grid-column: #{$j + 1};
    }
  }
}

.panel {
  display: flex;
  margin-bottom: 1em;
  justify-content: space-between;
}
ul {
  list-style: none;
  padding: 0;
}
body {
  width: 550px;
}
            
          
!
            
              const properties = {
  jc: 'justify-content',
  ac: 'align-content',
  ji: 'justify-items',
  ai: 'align-items',
  js: 'justify-self',
  as: 'align-self'
}

for (let key in properties) {
  let controls = document.getElementsByName(key);

  controls.forEach(function(item) {
    if (key === 'as' || key === 'js' ) {
      item.addEventListener('change', event=>{
        console.log(event.target.parentNode.parentNode)
        event.target.parentNode.parentNode.style.setProperty(properties[key],event.target.value);
      });
    }
    else {
      item.addEventListener('change', event=>{
        document.getElementById('grid').style.setProperty(properties[key],event.target.value);
        document.getElementById('flex').style.setProperty(properties[key],event.target.value);
      })
    }
  });
}
            
          
!
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