【发布时间】:2020-06-07 19:58:55
【问题描述】:
我编写了一张 Bootstrap 4 动画卡片:https://codepen.io/Steven2105/pen/ZEGLWma。
卡片默认显示标题,卡片文字应该是不可见的。 将鼠标悬停在卡片上后,文本也应该向上移动并可见。
所以我的问题是,如何隐藏卡片文本,只显示标题并使其在悬停后可见。
如果你向下滚动this page,你应该也会看到这样的卡片,我希望它们和它们一样。
.card-body {
margin-top: -58px;
background-color: rgba(0, 82, 204, 0.7);
}
.card:hover .card-body {
animation-duration: 0.6s;
animation-name: slidein;
animation-fill-mode:both;
margin-top: 0;
}
@keyframes slidein {
from {
transform: translateY(0);
}
to {
transform: translateY(-100%);
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="https://via.placeholder.com/150" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
【问题讨论】:
标签: css twitter-bootstrap css-animations