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 Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

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.

            
              <h1>Square Grid</h1>
<SquareGrid>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
</SquareGrid>
<h1>Smaller gutter:</h1>
<SquareGrid style="--gutter: 10px">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
</SquareGrid>

            
          
!
            
              // This is demo code and should be provided by your app product

.item{
  background-image: url('https://images.unsplash.com/photo-1484256017452-47f3e80eae7c?dpr=1&auto=format&fit=crop&w=2850&q=60&cs=tinysrgb');
  background-size: cover;
  background-position: center center;
  background-color: whitesmoke;
}
body{
  font-family: Noto Sans, Arial, sans-serif;
  padding: 3em 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}


// This is the component code that comes with 3 variables for modification

SquareGrid{
  // The content width you use on your website
  --content-width: 80vw;
  
  // The size of the gutter  
  --gutter: 40px;
  
  // The amount of columns
  --columns: 1;
  
  
  // This is the calculation for the row height.   
  --row-size: calc(
    ( var(--content-width) - (var(--gutter) * (var(--columns) - 1))
    ) / var(--columns)
  );
  
  display: grid;

  width: 100%;
  max-width: var(--content-width);
  
  grid-template-columns: repeat(var(--columns), 1fr);
  grid-auto-rows: var(--row-size);

  grid-column-gap: var(--gutter);
  grid-row-gap: var(--gutter);

}


// This is again demo. Just decide with media queries when to add another column 

@media (min-width: 450px){
  SquareGrid{
    --columns: 2;
  }
}

@media (min-width: 750px){
  SquareGrid{
    --columns: 3;
  }
}

@media (min-width: 1200px){
  SquareGrid{
    --columns: 4;
  }
}
            
          
!
999px
Loading ..................

Console