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="wrapper">
  <div class="container">
    <button>
      <img width="24px" alt="toggle dark mode" src="https://cdn-icons-png.flaticon.com/512/1628/1628629.png" />
    </button>
    <div class="content-grid">
      <article class="card espresso">
        <div class="coffee">
          <h1>Espresso</h1>
          <img src="https://jec.fyi/assets/img/demo/cof-cappucino.jpg">
          <p>Espresso is the name of a highly concentrated, bittersweet coffee originating in Italy in the early 20th century. Each shot of espresso is made to order upon customer request, as opposed to being brewed in anticipation of demand.
          </p>
          <a href="">Learn more</a>
        </div>
      </article>
      <article class="card mocha">
        <div class="coffee">
          <h1>Mocha</h1>
          <img src="https://jec.fyi/assets/img/demo/cof-cappucino.jpg">
          <p>Mocha is any type of chocolate-flavored coffee. It is often in iced, latte, or frappe form. Some Mocha recipes include some type of chocolate sauce (syrup, etc.), mixed in during the making of the coffee.
          </p>
          <a href="">Learn more</a>
        </div>
      </article>
      <article class="card cappucino">
        <div class="coffee">
          <h1>Cappucino</h1>
          <img src="https://jec.fyi/assets/img/demo/cof-cappucino.jpg">
          <p>A cappuccino is a coffee-based drink made primarily from espresso and milk. It consists of one-third espresso, one-third heated milk and one-third milk foam and is generally served in a 6 to 8-ounce cup.
          </p>
          <a href="">Learn more</a>
        </div>
      </article>
      <article class="card flat-white">
        <div class="coffee">
          <h1>Flat white</h1>
          <img src="https://jec.fyi/assets/img/demo/cof-cappucino.jpg">
          <p>A flat white is similar to a cappuccino but uses microfoam instead of dry foam. It is a coffee beverage from Australia and New Zealand. It is prepared by pouring microfoam (steamed milk from the bottom of a pitcher) over a single (30ml) or double shot (60ml) of espresso.
          </p>
          <a href="">Learn more</a>
        </div>
      </article>
    </div>
  </div>
</div>
              
            
!

CSS

              
                * {
  --color: #8b4513;
  --background-color: #eceff4;
  --article-background-color: white;
  --button-background: white;
}

@media (prefers-color-scheme: dark) {
  * {
    --color: wheat;
    --background-color: rgb(36, 41, 51);
    --article-background-color: rgb(46, 52, 64);
    --button-background: #d8dee9;
  }

  img {
    filter: grayscale(30%);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .card:hover {
    animation: 0.2s linear 0s alternate infinite annoying-animation;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card:hover {
    border-color: sandybrown;
  }
}

@media (prefers-contrast: more) {
  * {
    --color: black;
    --background-color: white;
    --article-background-color: white;
    --border-color: black;
  }
  
  .card {
    border-color: black
  }
}

@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  * {
    --color: white;
    --background-color: black;
    --article-background-color: black;
    --border-color: white;
  }
  
  .card {
    border-color: white;
  }
}

button {
  border: 0;
  background: #2fd772;
/*   background-image: linear-gradient(to right, #ff6e7f 0%, #bfe9ff  51%, #ff6e7f  100%); */
  margin: 10px;
  padding: 12px;
  text-align: center;
  background-size: 200% auto;
  color: white;            
  box-shadow: 0 0 20px #eee;
  border-radius: 10px;
  display: block;
  cursor: pointer;
  align-self: flex-end;
}

/* @media (forced-colors: active) {
  button {
    outline: 2px solid;
  }
  
  button img {
    display: none;
  }
  
  button::before {
    content: "Give feedback!"
  }
} */

body {
  color: var(--color);
  font-family: "Google Sans";
  font-size: 18px;

  margin: 0;
  min-height: 100vh;
  transition: background-color 300ms ease-in-out 0s;
  
  background-color: var(--background-color);
}

article {
  border-radius: 10px;
  border: 2px solid;
  padding: 0px 20px;
  margin: 10px;
  background: var(--article-background-color);
  transition: box-shadow 400ms ease-in-out 0s,
    background-color 400ms ease-in-out 0s;
}

p {
  line-height: 1.6;
}

img {
  border-radius: 20px;
}

.card a,
main p,
h1 {
  color: var(--color);
}

.wrapper {
  width: 100%;
  height: calc(100vh - 20px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: 100%;
  height: 90%;
  max-width: 900px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-areas: "headline headline" "big minor1" "big minor2";
}

.espresso {
  grid-area: big;
}

.cappucino {
  grid-area: headline;
}

.mocha {
  grid-area: minor1;
}

.flat-white {
  grid-area: minor2;
}

.card a {
  border-bottom: initial;
}

.card img {
  width: 100%;
}

.card h1 {
  padding: 0;
  color: var(--color);
}

.card {
  resize: horizontal;
  overflow: auto;
  min-width: 200px;
  max-width: 900px;
  container-type: inline-size;
  padding-bottom: 0.83em;
}

.feedback-button img {
  width: 24px;
}

@media (prefers-reduced-motion: no-preference) {
  .card:hover {
    transform: scale(1.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card:hover {
    transform: none;
    border-color: sandybrown;
  }
}

@media only screen and (max-width: 800px) {
  .content-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas: "headline" "big" "minor1" "minor2";
  }
}

@media only screen and (max-width: 400px) {
  .content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "headline big" "minor1 minor2";
  }
}

/* clean-css ignore:start */
@media only screen and (max-width: 923px) {
  @container (max-width: 399px) {
    .card.espresso p,
    .card.cappucino p {
      display: block;
    }
  }
}

@container (inline-size < 399px) {
  .card p {
    display: none;
  }

  .card a {
    padding-block: 10px;
  }
}

@container (inline-size > 400px) {
  .card p {
    display: block;
  }
}

@container (inline-size > 600px) {
  .card p,
  .card a {
    margin-left: 20px;
  }

  .card h1 {
    grid-column: 1/3;
  }

  .card img {
    grid-area: img;
  }

  .coffee {
    display: grid;
    grid-template-columns: 280px auto;
    grid-template-areas: "title title" "img desc" "img link";
  }

  .card a {
    grid-row: 3;
    grid-column: 2;
  }
}

@keyframes annoying-animation {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.4);
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console