Advent

Day 17: Card 🎴

A card component usually displays an image and extra information in card-like format.

The example component is visible below.


Santa Claus looking at camera with his mouth open.

Santa Claus

Age: 1,751

Location: North Pole


A few notes about this card component:

  • CSS Variables are used for colors,
  • the aspect-ratio is used to fit the image in the box.

The code:

<div class="advent-card">
  <div class="advent-card__image">
    <img src="https://res.cloudinary.com/starbist/image/upload/v1639658534/pexels-andrea-piacquadio-716658_gxpv08.jpg" alt="Santa Claus looking at camera with his mouth open." width="400" height="400">
  </div>
  <div class="advent-card__content">
    <h2>Santa Claus</h2>
    <p>Age: <b>1,751</b></p>
    <p>Location: <b>North Pole</b></p>
  </div>
</div>
.advent-card {
  --color-xmas-alpha: #f7efef;
  --color-xmas-beta: #d72621;

  background-color: var(--color-xmas-alpha);
  border: 1px double var(--color-xmas-beta);
  border-radius: .5em;

  max-width: 20rem;
  margin: auto;

  overflow: hidden;
}
.advent-card__image {
  background-color: var(--color-xmas-beta);
  aspect-ratio: 2 / 1;
  object-fit: cover;
}
.advent-card__content {
  color: var(--color-xmas-beta);
  padding: .5em .75em;
}
.advent-card__content h2 {
  font-size: 1.5rem;
  margin: 0;
}
.advent-card__content h2 {
  font-size: 1.5rem;
  margin: 0;
}
.advent-card__content p {
  font-size: .9rem;
  margin-top: .5em;
  margin-bottom: 0;
}

Advent of UI components 🎄

Check other UI components.

Day 24: Details 🎹

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 24: Details.

Day 23: Radio button 📱

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 23: Radio button.

Day 22: Checkbox 🧦

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 22: Checkbox.

Day 21: Notification 🤫

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 21: Notification.

Day 20: Code block 💻

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 20: Code block.

Day 19: Pagination 📖

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 19: Pagination.

Day 18: Social share 🔗

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 18: Social share.

Day 16: Table 🎶

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 16: Table.

Day 15: Breadcrumb 🍞

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 15: Breadcrumb.

Day 14: Blockquote 💬

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 14: Blockquote.

Day 13: List 🗒️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 13: List.

Day 12: Figure 🖼️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 12: Figure.

Day 11: Video embed 📺

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 11: Video embed.

Day 10: Footer 👇

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 10: Footer.

Day 9: Header ☝️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 9: Header.

Day 8: Hero 🦸‍♂️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 8: Hero.

Day 7: Intro 💬

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 7: Intro.

Day 6: Horizontal rule 〰️

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 6: Horizontal rule.

Day 5: Split 💔

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 5: Split.

Day 4: Banner 🚩

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 4: Banner.

Day 3: Gallery 🍿

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 3: Gallery.

Day 2: Tag 🎁

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 2: Tag.

Day 1: Button 🎅

During every day of the Advent of UI components, I am showcasing a new UI Component built with HTML, CSS, and JavaScript. Day 1: Button.