【发布时间】:2022-01-06 07:46:39
【问题描述】:
我被这个 CSS 动画卡住了。 悬停时框架应该是动画的。从顶部中心开始,一直画到最后。
有人对此有解决方案吗?
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
body{
font-family: 'Roboto', sans-serif;
}
a.teaser-card-link {
text-decoration: none;
}
.card{
background-size: cover !important;
background-repeat: no-repeat !important;
max-width: 425px;
border-radius: 10px;
overflow: hidden;
}
.caption {
padding: 20px;
}
.dark-cover:hover {
background: url('https://svgshare.com/i/cP2.svg');
background-repeat: no-repeat;
background-attachment: fixed;
}
.card .caption p.card-title{
font-size: 22px;
font-weight: bold;
text-align: left;
margin: 0;
padding: 0;
letter-spacing: 1px;
padding-bottom: 20px;
margin-top: 10px;
}
.card .caption p.card-description{
font-size: 16px;
font-weight: 300;
text-align: left;
margin: 0;
padding: 0;
letter-spacing: 1px;
line-height: 1.5em;
padding-bottom: 20px;
}
.card .caption a.link-text{
font-size: 16px;
font-weight: 300;
text-align: left;
margin: 0;
padding: 0;
letter-spacing: 1px;
line-height: 1.5em;
text-decoration: none;
color: blue;
}
a.teaser-card-link {
text-decoration: none;
}
<div class="card">
<div class="dark-cover">
<div class="cover">
<img src="https://i.stack.imgur.com/jLbFE.png" class="card-image">
<div class="caption">
<p class="card-title">CARD-TEST</p>
<p class="card-description">Hier kannst du dich austauschen und offen über deine Gefühle und Sorgen sprechen.</p>
<a href="#" class="link-text">Hier mehr erfahren</a>
</div>
</div>
</div>
</div>
到目前为止,我已经掌握了 HTML/CSS。我不知道哪种技术最适合这个。 SVG、PNG 或纯 CSS,因为这在技术上是一个边框。
<svg class="svg-border" xmlns="http://www.w3.org/2000/svg" width="409" height="273" viewBox="0 0 409 273" fill="none">
【问题讨论】:
-
我不确定我脑海中的答案,但如果您查看这 23 个动画边框,您可能会在为每个边框提供的代码中找到一些线索。 freefrontend.com/css-border-animations
-
你也可以在这里上传你的矢量图吗?理想情况下,SO 上的内容应该是独立的。
-
@tylerH 更新 + 添加资产。