Skip to content

Animation

This is a card

Use it to provide a small amount of information, link to another webpage, and give your page visual interest.

---
const { customClasses } = Astro.props;
const defaultClasses = "card theme container";
const classes = customClasses
  ? `${defaultClasses} ${customClasses}`
  : defaultClasses;
---

<div class={classes}>
  <div class="image">
    <img src="/images/card-padilla.jpg" alt="" />
  </div>
  <div class="card-body l-stack">
    <h2>
      <a href="#">This is a card</a>
    </h2>
    <p>
      Use it to provide a small amount of information, link to another webpage,
      and give your page visual interest.
    </p>
  </div>
</div>

I like this drop shadow generator

This is a card

Use it to provide a small amount of information, link to another webpage, and give your page visual interest.

.card.-animation-lift {
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  translate: 0 0;
  transition: all 150ms linear;

  &:hover {
    box-shadow: var(--shadow-elevation-medium);
    translate: 0 -3px;
  }
}
<div class="l-stack">
  <a class="button -animation-arrow" href="/" style="margin-right: auto;">
    Learn More
    <svg width="20" viewBox="0 0 23 23">
      <g id="chevron">
        <polygon
          points="11.3 0 9.7 1.6 18.3 10.2 18.3 10.2 19.5 11.3 18.3 12.5 18.3 12.5 9.7 21.1 11.3 22.7 22.7 11.3 11.3 0"
          fill="currentColor"></polygon>
      </g>
      <g id="stem">
        <polygon
          points="18.3 10.2 15.1 10.2 0 10.2 0 12.5 15.1 12.5 18.3 12.5 19.5 11.3 18.3 10.2"
          fill="currentColor"></polygon>
      </g>
    </svg>
  </a>
</div>
.button.-animation-scale {
  position: relative;
  background-color: transparent;

  >* {
    position: relative;
    z-index: 2;
  }

  &::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--black);
    scale: 1;
    transition: scale 150ms linear;
  }

  &:hover::before {
    scale: 1.07;
  }
}
.button.-animation-translate {
  transition: all 150ms ease;
  translate: 0 0;

  &:hover {
    translate: 0 -5px;
  }
}
.button.-animation-fill {
  position: relative;
  overflow: hidden;

  >* {
    color: var(--black);
    transition: color 300ms linear;
    position: relative;
    z-index: 2;
  }

  &:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--black);
    translate: 0 100%;
    transition: translate 200ms var(--ease-out-5);
    z-index: 1;
  }

  &:hover>* {
    color: var(--white);
  }

  &:hover:before {
    translate: 0 0;
  }
}

This requires using a variable font to transition the weight and box-shadow to transition the border.

.button.-animation-border-font-weight {
  transition: all 150ms ease;

  >* {
    transition: all 150ms ease;
    font-weight: 500;
  }

  &:hover {
    box-shadow: 0 0 0 3px currentColor;

    >* {
      font-weight: 800;
    }
  }
}

Link to examples

Link to examples