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

              
                <section class="wrapper">
  <h2 class="heading">Blog Posts</h2>
  <main>
    <article data-custom="true">
      <img
        src="https://images.unsplash.com/photo-1524758631624-e2822e304c36?crop=entropyq=80&w=400"
        alt=""
      />

      <h2 class="p7">Lorem ipsum dolor sit dolor consectetur</h2>
      <div class="description">
        Lorem ipsum dolor sit amet elit dolor consectetur elit
        dolor amet ande.
      </div>
      <div class="read__more">Read more</div>
    </article>
    <article>
      <img
        src="https://images.unsplash.com/photo-1650542918181-ba360683d936?crop=entropyq=80&w=400"
        alt=""
      />

      <h2 class="p7">
        Lorem ipsum, dolor sit amet consectetur adipisicing
      </h2>
      <div class="read__more">Read more</div>
    </article>
    <article>
      <img
        src="https://images.unsplash.com/photo-1497215728101-856f4ea42174?crop=entropyq=80&w=400"
        alt=""
      />

      <h2 class="p7">Mollitia commodi, earum vitae</h2>
      <div class="read__more">Read more</div>
    </article>
    <article>
      <img
        src="https://images.unsplash.com/photo-1650548158371-d48266a26887?crop=entropyq=80&w=400"
        alt=""
      />

      <h2 class="p7">maxime excepturi odio quasi voluptates</h2>
      <div class="read__more">Read more</div>
    </article>
    <article data-custom="true">
      <img
        src="https://images.unsplash.com/photo-1650614967039-1cb97737df86?crop=entropyq=80&w=400"
        alt=""
      />
      <h2 class="p7">laboriosam iste quis, nihil dolor</h2>
      <div class="read__more">Read more</div>
    </article>
    <article>
      <img
        src="https://images.unsplash.com/photo-1650639012849-c66a018e107a?crop=entropyq=80&w=400"
        alt=""
      />
      <h2 class="p7">
        voluptatem dolore. Numquam Veniam deleniti
      </h2>
      <div class="read__more">Read more</div>
    </article>
    <article>
      <img
        src="https://images.unsplash.com/photo-1650637472771-16fedc3c6668?crop=entropyq=80&w=400"
        alt=""
      />

      <h2 class="p7">
        amet consectetur adipisicing elit amet consectetur
      </h2>
      <div class="read__more">Read more</div>
    </article>
    <article>
      <img
        src="https://images.unsplash.com/photo-1650653823792-31256d087311?crop=entropyq=80&w=400"
        alt=""
      />
      <h2 class="p7">Totam iusto adipisci quidem</h2>
      <div class="read__more">Read more</div>
    </article>
  </main>
</section>
              
            
!

CSS

              
                main {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(300px, 100%), 1fr)
  );
  gap: 1rem;
  grid-auto-rows: 180px 1fr auto;
  grid-auto-flow: dense;
}

article {
  box-shadow: rgba(0, 0, 0, 0.16) 0px 2px 8px;
  background-color: rgb(255, 255, 255);
  border-radius: 0.5rem;
  overflow: hidden;
  
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  row-gap: 0px;
}

img {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;

  width: 100%;
  display: block;
/*   height: 180px; */
  height: 100%;
  object-fit: cover;
}

h2 {
  font-size: 19px;
}

.p7 {
  padding: 7px;
}

.read__more {
  color: blue;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
  padding: 7px;
}


* {
  box-sizing: border-box;
  margin: 0;
}

body,
html {
  height: 100vh;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0 auto;
}

.wrapper {
  max-width: 1280px;
  margin: 4rem auto;
  padding-inline: 1rem;
}

.heading {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.description {
  display: none; /* Hide description by default */
  font-size: 13px;
  padding: 0 7px 7px;
}

article[data-custom='true'] {
  @media (min-width: 996px) {
    grid-column: span 2;
    grid-template-columns: subgrid;

    > img {
      grid-column: 1 / -1;
    }

    > h2 {
      grid-column: 1 / -1;
      font-size: 30px;
    }

    .description {
      display: block;
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console