【发布时间】:2017-06-11 07:06:30
【问题描述】:
我目前有一个小 SVG,可以添加完整的笔画。但是,我很难在 hover 上完成一个完整的循环。当用户将鼠标悬停在链接之外时,它应该返回另一个方向。
完整的动画似乎可以正常工作,但是在集成它时,当我只想让它发生时,动画却不断消失。
body,
html {
position: relative;
height: 100%;
}
body {
background-color: #D81D3B;
}
.svg-container {
position: absolute;
top: 50%;
left: 50%;
width: 7em;
height: 7em;
transform: translate3d(-50%, -50%, 0);
}
.svg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
}
.symbol {
fill: transparent;
stroke: #fff;
stroke-width: 1px;
stroke-dasharray: 1600;
stroke-miterlimit: 10;
stroke-dashoffset: 1600;
animation: dash 4s linear 1;
}
@keyframes dash {
from {
stroke-dashoffset: 1600;
}
to {
stroke-dashoffset: -1600;
}
}
<div class="svg-container">
<svg width="100" height="100" class="svg">
<circle cx="50" cy="50" r="40" stroke-width="4" class="symbol" />
</svg>
</div>
<a href="#">Stupid</a>
【问题讨论】:
-
我很难理解默认状态和悬停状态应该是什么。请说明您正在尝试的确切行为。
-
@SophieRhodes:我添加了一些标签,它们可能对未来的搜索有所帮助。如果您觉得它们不正确,请随时回滚。
标签: javascript html css svg css-animations