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

              
                <div class="container container__hero">
  <div class="card">
    <img src="https://picsum.photos/2568/600?random=1" width="2568" height="600" alt="" class="card__thumbnail" />
    <div class="card__badge">Must Try</div>
    <h3 class="card__title">Best Brownies in Town</h3>
    <p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
    <button class="card__button">Order now</button>
  </div>
</div>

<div class="container container__sidebar">
  <div class="card">
    <img src="https://picsum.photos/2568/600?random=2" width="2568" height="600" alt="" class="card__thumbnail" />
    <div class="card__badge">Must Try</div>
    <h3 class="card__title">Best Brownies in Town</h3>
    <p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
    <button class="card__button">Order now</button>
  </div>
  <div class="card">
    <img src="https://picsum.photos/2568/600?random=3" width="2568" height="600" alt="" class="card__thumbnail" />
    <div class="card__badge">Must Try</div>
    <h3 class="card__title">Best Brownies in Town</h3>
    <p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
    <button class="card__button">Order now</button>
  </div>
  <div class="card">
    <img src="https://picsum.photos/2568/600?random=4" width="2568" height="600" alt="" class="card__thumbnail" />
    <div class="card__badge">Must Try</div>
    <h3 class="card__title">Best Brownies in Town</h3>
    <p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
    <button class="card__button">Order now</button>
  </div>
</div>

<div class="container container__aside">
  <div class="card">
    <img src="https://picsum.photos/2568/600?random=5" width="2568" height="600" alt="" class="card__thumbnail" />
    <div class="card__badge">Must Try</div>
    <h3 class="card__title">Best Brownies in Town</h3>
    <p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
    <button class="card__button">Order now</button>
  </div>
  <div class="card">
    <img src="https://picsum.photos/2568/600?random=6" width="2568" height="600" alt="" class="card__thumbnail" />
    <div class="card__badge">Must Try</div>
    <h3 class="card__title">Best Brownies in Town</h3>
    <p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
    <button class="card__button">Order now</button>
  </div>
</div>
<div class="container container__main">
  <div class="card">
    <img src="https://picsum.photos/2568/600?random=7" width="2568" height="600" alt="" class="card__thumbnail" />
    <div class="card__badge">Must Try</div>
    <h3 class="card__title">Best Brownies in Town</h3>
    <p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
    <button class="card__button">Order now</button>
  </div>
  <div class="card">
    <img src="https://picsum.photos/2568/600?random=8" width="2568" height="600" alt="" class="card__thumbnail" />
    <div class="card__badge">Must Try</div>
    <h3 class="card__title">Best Brownies in Town</h3>
    <p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
    <button class="card__button">Order now</button>
  </div>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");

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

body {
  width: 100vw;
  min-height: 100vh;
  font-family: "Exo", Arial, sans-serif;
  background-color: #557;

  display: grid;
  gap: 20px;
  align-items: start;
  grid-template-columns: 480px 1fr 220px;
  grid-template-areas:
    "hero hero hero"
    "sidebar main aside";
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.container__hero {
  grid-area: hero;
  width: 100%;
}

.container__sidebar {
  grid-area: sidebar;
  display: grid;
  justify-content: center;
  gap: 20px;
  padding: 0 10px;
  width: 100%;
}

.container__aside {
  grid-area: aside;
  display: grid;
  justify-content: center;
  gap: 20px;
  padding: 0 10px;
  width: 100%;
}

.container__main {
  grid-area: main;
  display: grid;
  justify-content: center;
  gap: 20px;
  width: 100%;
}
.card {
  display: grid;
  border-radius: 10px;
  background-color: #fff;
  color: #454545;
  gap: 10px;
  box-shadow: 0 0 0.35em 0 rgb(0 0 0 / 0.5);
}

.card__thumbnail {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  border-radius: 10px 10px 0 0;
  grid-area: 1 / 1 / 2 / 2;
  z-index: 1;
}

.card__badge {
  grid-area: 1 / 1 / 2 / 2;
  z-index: 2;
  background-color: #2196f3;
  border-radius: 0 10rem 10rem 0;
  align-self: start;
  justify-self: start;
  margin-top: 2rem;
  color: #fff;
  padding: 5px 12px 5px 8px;
  text-shadow: 0 0 1px rgb(0 0 0 / 0.5);
  filter: drop-shadow(0px 0px 2px rgb(0 0 0 / 0.5));
}

.card__title {
  font-weight: 700;
  font-size: clamp(1.2rem, 1.2rem + 3vw, 1.5rem);
  padding: 0 20px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.card__describe {
  color: #666;
  line-height: 1.4;
  padding: 0 20px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.card__button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: none;
  border-radius: 10rem;
  background-color: #feca53;
  padding: 10px 20px;
  color: #000;
  text-decoration: none;
  box-shadow: 0 3px 8px rgb(0 0 0 / 7%);
  transition: all 0.2s linear;
  font-weight: 700;
  justify-self: end;
  margin: 0 20px 20px 0;
  cursor: pointer;
}

.card__button:hover {
  background-color: #ff9800;
}

/* CSS Container Queries*/

.container {
  contain: layout inline-size style;
}

/* container's width > 400px*/

@container (min-width: 400px) {
  .card {
    grid-template-columns: 180px auto;
    grid-template-areas:
      "thumbnail title"
      "thumbnail button";
  }

  .card__thumbnail {
    grid-area: thumbnail;
    aspect-ratio: 1 / 1;
    border-radius: 10px 0 0 10px;
  }

  .card__badge,
  .card__describe {
    display: none;
  }

  .card__title {
    grid-area: title;
    margin-top: 20px;
    align-self: start;
  }

  .card__button {
    grid-area: button;
    align-self: end;
  }
}

/* container's width > 550px*/

@container (min-width: 550px) {
  .card {
    grid-template-columns: 240px auto;
    grid-template-rows: min-content min-content auto;
    grid-template-areas:
      "thumbnail title"
      "thumbnail describe"
      "thumbnail button";
    gap: 0;
  }

  .card__thumbnail {
    grid-area: thumbnail;
    aspect-ratio: 1 / 1;
    border-radius: 10px 0 0 10px;
    z-index: 1;
  }

  .card__badge {
    grid-area: thumbnail;
    z-index: 2;
    display: flex;
  }
  .card__describe {
    grid-area: describe;
    align-self: start;
    display: flex;
    margin-top: -24px;
  }

  .card__title {
    grid-area: title;
    margin-top: 20px;
    align-self: start;
  }

  .card__button {
    grid-area: button;
    align-self: end;
  }
}

/* container's width > 700px*/

@container (min-width: 700px) {
  .card {
    grid-template-areas:
      "title title title"
      "describe describe describe"
      "button button button";
    grid-template-rows: none;
    grid-template-columns: none;
    grid-auto-rows: auto;
    align-items: center;
    justify-content: center;
    align-content: center;
    border-radius: 0;
  }

  .card::after,
  .card::before {
    content: "";
    display: block;
    grid-area: 1 / 1 / 4 / 4;
    z-index: 2;
    background-image: linear-gradient(
      -45deg,
      #ee7752,
      #e73c7e,
      #23a6d5,
      #23d5ab
    );
    background-size: 100vw 100vw;
    background-color: rgb(0 0 0 / 0.5);
    opacity: 0.5;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
  }

  .card::before {
    z-index: 3;
  }
  .card > * {
    z-index: 4;
    justify-self: center;
  }

  .card__thumbnail {
    grid-area: 1 / 1 / 4 / 4;
    aspect-ratio: 16 / 9;
    border-radius: 0;
    max-height: 280px;
    z-index: 1;
  }

  .card__badge {
    grid-area: 1 / 1 / 4 / 4;
    justify-self: start;
    z-index: 5;
  }

  .card__title {
    grid-area: title;
    align-self: end;
    margin-top: 0;
    color: #fff;
    font-size: clamp(2rem, 2rem + 4vw, 3rem);
  }

  .card__describe {
    grid-area: describe;
    margin-top: 0;
    max-width: 60vw;
    color: #fff;
    text-align: center;
    font-size: clamp(1.2rem, 1.2rem + 2vw, 1.5rem);
  }

  .card__button {
    --purple: #7f00ff;
    --pink: #e100ff;
    grid-area: button;
    margin: 0;
    align-self: start;
    padding: 0.75em 4em;
    font-size: clamp(1.2rem, 1.2rem + 2vw, 1.5rem);
    text-shadow: 1px 1px 1px rgb(0 0 0 / 50%);
    text-transform: uppercase;
    background: linear-gradient(to right, var(--purple), var(--pink));
    position: relative;
    color: #fff;
  }

  .card__button::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    opacity: 0.8;
    border-radius: 10rem;
    background: inherit;
    filter: blur(30px);

    transition: all 0.2s;
  }

  .card__button:hover::after {
    filter: blur(32px);
    bottom: -5px;
  }

  .card__button:hover:active::after {
    filter: blur(10px);
    bottom: -6px;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console