【发布时间】:2020-05-21 05:08:58
【问题描述】:
正如标题所述,我正在尝试为虚线箭头设置动画。我希望它在this site 上看起来尽可能接近。
虽然我不确定这是制作这种箭头的正确方法,但我能够制作箭头。我假设我必须用 SVG 绘制它......
而且动画看起来很奇怪,我不知道如何使它更流畅......
我会很感激一些帮助:)
代码如下:
body {
margin: 0;
font-size: 16px;
line-height: 1.528571429;
padding: 0;
height: 100%;
}
body #contact {
height: calc(100vh - 40px);
background-color: #ffffff;
}
body #contact .to-top-btn-wrapper {
position: absolute;
z-index: 999;
left: 7%;
bottom: 15%;
}
body #contact .to-top-btn-wrapper .btn-text-wrapper {
margin: -35px auto;
}
body #contact .to-top-btn-wrapper .btn-text-wrapper .btn-text {
font-size: 14px;
letter-spacing: 0.25em;
text-align: center;
color: #676565;
text-transform: uppercase;
}
body #contact .to-top-btn-wrapper .to-top-btn {
position: absolute;
top: 0;
left: 35px;
bottom: 25px;
cursor: pointer;
}
body #contact .to-top-btn-wrapper .to-top-btn .line {
border-right: 0.1rem dashed #676565;
display: inline-block;
animation: show 1000ms linear forwards infinite;
}
body #contact .to-top-btn-wrapper .to-top-btn .arrow {
position: absolute;
top: -0.3rem;
bottom: 0;
height: 1rem;
border-right: 0.1rem solid #676565;
display: inline-block;
}
body #contact .to-top-btn-wrapper .to-top-btn .right {
left: 0.3rem;
transform: rotate(-45deg);
}
body #contact .to-top-btn-wrapper .to-top-btn .left {
right: 0.3rem;
transform: rotate(45deg);
}
@keyframes show {
0% {
height: 5rem;
}
100% {
height: 0rem;
}
}
<section id="contact" class="container-fluid">
<div class="to-top-btn-wrapper">
<div class="btn-text-wrapper">
<span class="btn-text">Scroll to top</span>
</div>
<div class="to-top-btn">
<span class="arrow left"></span>
<span class="line"></span>
<span class="arrow right"></span>
</div>
</div>
</section>
【问题讨论】:
-
检查您提供的页面上的代码,给出答案。为什么不遵循他们的做法?这没什么花哨的。他们使用关键帧来动画“变换”,值为
matrix3d -
好的,不仅仅是
matrix3d。查看容器中的每个元素。他们使用了很多技巧。但大多数是使用动画完成的。您可以使用关键帧。似乎他们正在使用 JS,因为它是元素样式。
标签: javascript html css css-animations