css实现十种文字按钮动画效果代码

代码语言:html

所属分类:动画

代码描述:css实现十种文字按钮动画效果代码

代码标签: css 十种 文字 按钮 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/open-props.easings.css">
<style>

@keyframes shake {
  50% {
    transform: translate3d(20px, 0, 0);
  }
}

@keyframes flip {
  100% {
    transform: rotateY(180deg);
  }
}

@keyframes pulse {
  50% {
    transform: scale(1.5);
  }
}

@keyframes glitch {
  50% {
    transform: skew(180deg);
  }
}

@keyframes fill {
  50% {
    transform: translateX(-5%);
  }
}

@keyframes sheen {
  100% {
    transform: rotateZ(60deg) translate(1em, -9em);
  }
}

@keyframes glow {
  50% {
    box-shadow: 0 0 40px hsl(12, 100%, 60%);
  }
}

@keyframes tonyhawk {
  50%,
  100% {
    transform: rotate(900deg);
  }
}

@keyframes blur {
  50% {
    filter: blur(20px);
    transform: skew(45deg);
  }
}

[anim="shake"]:not(.toggled) {
  animation: shake var(--ease-elastic-in-1) 300ms infinite alternate;
}

[anim="pulse"]:not(.toggled) {
  animation: pulse var(--ease-elastic-in-1) 400ms infinite alternate;
}

[anim="glitch"]:not(.toggled) {
  animation: glitch var(--ease-elastic-in-1) 6ms infinite;
}

[anim="tonyhawk"]:not(.toggled) {
  animation: tonyhawk var(--ease-elastic-in-1) 600ms infinite;
}

[anim="flip"]:not(.toggled) {
  animation: flip var(--ease-elastic-in-1) 600ms infinite alternate;
}

[anim="fill"]:not(.toggled)::after {
  animation: fill var(--ease-spring-1) 8000ms infinite;
}

[anim="sheen"]:not(.toggled)::after {
  animation: sheen var(--ease-elastic-in-1) 1s infinite;
}

[anim="glow"]:not(.toggled) {
  animation: glow var(--ease-elastic-in-1) 600ms infinite alternate;
}

[anim="blur"]:not(.toggled) {
  animation: blur var(--ease-elastic-in-1) 1s infinite alternate;
}

[anim="fill"]::after {
  content: "";
  color: var(--black);
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  height: 100%;
  width: 200%;
  inset: 0;
  transform: translateX(-400px);
  background-color: hsl(12, 90%, 63%);
}

[anim="sheen"]::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  bottom: -50%;
  left: -50%;
  background: var(--red-sheen);
  transform: rotateZ(60deg) translate(-5em, 7.5em);
}

:root {
  --black: hsl(0, 0%, 13%);
  --dark: hsl(12, 32%, 2%);
  --gray: hsl(0, 0%, 70%);
  --white: hsl(0, 0%, 96%);
  --red: hsl(12, 90%, 63%);
  --red-shadow: hsl(12, 100%, 60%);
  --red-sheen: linear-gradient(
    to bottom,
    hsl(12, 90%, 43%),
    hsla(12, 40%, 70%, 0.5) 50%,
    hsl(12, 93%, 23%)
  );
}

html,
body {
  background-color: var(--black);
}

div:has(h2 + p) {
  display: grid;
  gap: 8px;
}

h2 {
  font-size: 1.25rem;
}

h2 + p {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
  font-size: 0.875rem;
}

main {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  justify-content: center;
  align-items: center;
}

article {
  display: flex;
  flex-wrap: wrap;
  gap: 64px;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  position: relative;

  &::after {
    content: "";
    width: 100%;
    position: absolute;
    height: 1px;
    bottom: 0;
    background-image: linear-gradient(45deg, var(--red), transparent 70%);
  }
}

section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-basis: 180px;
  justify-content: center;
  align-items: center;
  text-align: center;
}

section {
  color: var(--white);
  font-family: "aglet-mono-variable", sans-serif;
  font-variation-settings: "wght" 400;
}

* {
  font-family: inherit;
  box-sizing: border-box;
}

button {
  all: unset;
  background-color: var(--black);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--red);
  box-shadow: 0 0 4px var(--red-shadow);
  cursor: pointer;
  perspective: 1000px;
  position: relative;
  overflow: hidden;
}

.blurry {
  position: relative;
  transform-style: preserve-3d;
}

.blurry::before {
  content: "";
  position: absolute;
  inset: 0px;
  transform: translate3d(0px, 0px, -1px);
  background: var(--red-shadow);
  filter: blur(6px);
}
</style>


  
  
</head>

<body translate="no">
  <main>
  <article>
    <section>
      <div>
        <h2>Shakes</h2>
        <p>Rejecting</p>
      </div>
      <div>
        <button anim="shake">CLICK ME</button>
      </div>
    </section>
    <section>
      <div>
        <h2>Pulse</h2>
        <p>Partyin.........完整代码请登录后点击上方下载按钮下载查看

网友评论0