【发布时间】:2021-07-04 21:52:36
【问题描述】:
在本网站的最开始https://hype4.com/,在“我们建造”这个词之后有一个文字动画。我试图找出它是如何制作的。我只得到了相关的 CSS 部分。但是,找不到 JS 部分。
HTML 部分
<h1 class="mainPrimaryHeading mainPrimaryHeading2020">
<span class='topText'>We build
<span class='textGradient noAfter animationRotateText'>
<span class='word'>successful</span>
<span class='word'>converting</span>
<span class='word'>functional</span>
<span class='word'>lovable</span>
<span class='word'>engaging</span>
<span class='word'>memorable</span>
</span>
</span>
<strong class='bottomText'>web and mobile products</strong>
</h1>
CSS 样式和类
.mainPrimaryHeading {
font-size: 60px;
letter-spacing: .99px;
margin: 0 auto 42px auto;
line-height: 63px;
font-weight: 900;
}
.topText{
position: relative;
}
.animationRotateText {
display: inline-block;
vertical-align: top;
margin: 0;
width: 300px;
height: 60px;
line-height: 1.3;
}
.textGradient {
position: relative;
background: -webkit-linear-gradient(319.11deg,#5668f2 0%,#b77dfb 100%);
background-clip: text;
-webkit-text-fill-color: transparent;
}
.word {
position: absolute;
width: 340px;
opacity: 0;
top: -8px;
left: 0;
left: 50%;
-webkit-transform: translate(-50%,0);
transform: translate(-50%,0);
margin: 0 0 0 19px;
}
.letter {
display: inline-block;
position: relative;
float: left;
-webkit-transform: translateZ(25px);
transform: translateZ(25px);
-webkit-transform-origin: 50% 50% 25px;
transform-origin: 50% 50% 25px;
background: -webkit-linear-gradient(319.11deg,#5668f2 0%,#b77dfb 100%);
background-clip: text;
-webkit-text-fill-color: transparent;
}
.letter.out {
-webkit-transform: rotateX(90deg);
transform: rotateX(90deg);
-webkit-transition: -webkit-transform 0.32s cubic-bezier(.55,.055,.675,.19);
transition: -webkit-transform 0.32s cubic-bezier(.55,.055,.675,.19);
transition: transform 0.32s cubic-bezier(.55,.055,.675,.19);
transition: transform 0.32s cubic-bezier(.55,.055,.675,.19),
-webkit-transform 0.32s cubic-bezier(.55,.055,.675,.19);
}
在 CSS 文件中有名为 .letter 和 .out 的样式类。这两个样式类不包含在 html 文件中。这意味着这些是由 JavaScript 添加的样式类。但我可以找到关联的 JS 部分。
如果有人能说出它是如何制作的或任何教程链接,我会很高兴。提前致谢
【问题讨论】:
标签: javascript html css animation text