html - 动画的问题
问题描述
我正在尝试在图像上添加动画效果,以便当有人将鼠标悬停在图像上时,它将以特定角度移动然后返回。它工作但不正确。所以,我正在寻找你的帮助和建议。
问题是:
- 由于某种原因,任何图像都会在悬停时向下移动到另一个图像。您需要将鼠标悬停在每个图像上以复制此问题。我试图修复它,但没有任何效果。
- 悬停时,图像线性移动,但一旦我取消悬停该图像,它就会立即返回,无需任何时间。我希望它在向前移动时线性返回。它应该工作均匀。请帮忙。
这是页面网址:https ://aapsiindia.org/welcome/
这是CSS代码:
<style>
.vcard{
vertical-align: middle;
text-align:center;
column-count: 3;
column-gap: 0.5%;
width: 100%;
position: relative;
}
.card{
box-shadow: 3px 8px 8px 3px grey;
vertical-align: middle;
float: center;
text-align: center;
padding: 3%;
}
.card:hover {
opacity: 0.5;
box-shadow: 3px, grey;
transform: rotate(3deg);
transition: linear 2s;
}
</style>
我会感激你的!谢谢!
解决方案
您可以尝试使用@keyframes 制作动画,因为它们很流畅。
.card.over{
box-shadow: 3px 8px 8px 3px grey;
vertical-align: middle;
float: center;
text-align: center;
padding: 3%;
animation-name: ontop;
animation-duration:5s;
}
.card.out {
animation-name: away;
animation-duration:2s;
}
@keyframes away {
from {
transform: rotate(0deg);
}
to {
transform: rotate(10deg);
}
}
@keyframes ontop {
from {
transform: rotate(10deg);
}
to {
transform: rotate(0deg);
}
}
推荐阅读
- makefile - 仅当先决条件由先前的配方创建时才执行配方
- c# - 如何在 C# 中正确使用异步?
- javascript - 谷歌脚本 - 每次使用最新的工作表
- c# - 更改 ListView 中列的宽度(c#)
- swift - 为什么我的 Swift 三元运算符不起作用?
- google-cloud-data-fusion - Google Cloud Data Fusion MySQL 复制作业无法合并临时表中的一批更改
- java - 在两个 REST API 之间映射查询参数
- java - Spring AOP 看不到方法
- react-native - React Native 显示动画 SVG
- nestjs - Nest 无法解析 BookingService 的依赖关系