0

幻灯条标题_前端开发的技术博客_51CTO博客

 1 year ago
source link: https://blog.51cto.com/u_15473285/5867981
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

幻灯条标题

精选 原创

晨曦前端 2022-11-18 11:00:38 博主文章分类:css ©著作权

文章标签 ide javascript 文章分类 JavaScript 前端开发 阅读数301

<template>
  <header>
    <div class="box">
      标题一
      <p class="subtitle slide-bar">标题二</p>
    </div>
  </header>
</template>

<script>
export default {

}
</script>

<style lang="scss" scoped>
header{
  width: 600px;
  height: 600px;
  background: #222;
  display: flex;
  justify-content: center;
  align-items: center;
  .box{
    text-align: center;
  }
}

.slide-bar {
  position: relative;
  color: transparent;
  animation: fill-text-white 2s 1.6s forwards;

  &::before {
    position: absolute;
    content: "";
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #35b9f1;
    transform: scaleX(0);
    transform-origin: left;
    animation: slide-in-out 2s cubic-bezier(0.75, 0, 0, 1) forwards;
  }
}

@keyframes slide-in-out {
  50% {
    transform: scaleX(1);
    transform-origin: left;
  }

  50.1% {
    transform-origin: right;
  }

  100% {
    transform: scaleX(0);
    transform-origin: right;
  }
}

@keyframes fill-text-white {
  to {
    color: white;
  }
}

header {
  .title,
  .subtitle {
    width: 250px;
    height: 30px;
  }

  .title {
    margin: 0;
    font-family: Lora, serif;
    font-size: 32px;
    line-height: 30px;

    &::before {
      background: #FF4081;
    }
  }

  .subtitle {
    margin: 10px 0 0 0;
    font-family: Lato, sans-serif;
    font-size: 12px;
    line-height: 30px;
    letter-spacing: 5px;
    text-transform: uppercase;
    animation-delay: 3.2s;

    &::before {
      background: #03A9F4;
      animation-delay: 2s;
    }
  }
}
</style>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK