Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <main class="container">  
  <article class="card">
    <img src="https://picsum.photos/id/1015/300/200">
    <h3>Awesome place</h3>
    <p>This is an experiment on CSS subgrid and as such it only works in Firefox 71 at the moment. Code simplicity has been prioritised. For production code, consider at least some sort of CSS architecture and give the html some work to prevent a11y issues </p>
    <button> more info </button>
  </article>
  
  <article class="card">
    <img src="https://picsum.photos/id/1016/300/200">
    <h3>Much dryer, still awesome place</h3>
    <p>Can I lorem this? Of course I can. 
Lorem ipsum dolor sit amet consectetur adipisicing elit. Repellat quas tenetur perspiciatis iure ipsum</p>
    <button> more info </button>
  </article>
 
    <article class="card">
    <img src="https://picsum.photos/id/1018/300/200">
    <h3>The grass is greener</h3>
    <p>but the description is shorter..</p>
    <button> more info </button>
  </article>
</main>
              
            
!

CSS

              
                .container{
  display:grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
  grid-gap: 20px;
}

.card{
  max-width: 300px;
  display: grid;
  grid-gap: inherit;
  align-content: start;

}

@supports (grid-template-rows: subgrid){
  .container{
    /* declare the rows for the container*/
    grid-template-rows: repeat(4, auto);  
  }
  
  .card{
    /* gets the element to span all rows, to prevent overlapping */
    grid-row: span 4;
    /* sets the card row tracks to depend on the parent*/
    grid-template-rows: subgrid;
  }
}

/* easthetic styles, not related to the subgrid stuff */
body{
  background-color: wheat;
  font-family: sans-serif;
  display: flex;
  justify-content:center;
}

.container{
  margin: 40px 20px;
  justify-content: center;
}

.card{
  background: white;
  box-shadow: 0 0 10px;
  border-radius: 15px;
  overflow: hidden;
  padding-bottom: 20px;
}


img{
  max-width: 100%;
}

h3{
  margin:0 auto 0 auto;
  padding: 0 15px;
}

p{
  margin: 1rem 20px;
}

button{
  margin: auto;
  border: 2px solid transparent;
  background-color: teal;
  color: white;
  padding: 10px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: bold;
}
              
            
!

JS

              
                
              
            
!
999px

Console