我有这个div,当您将鼠标悬停时会在其中插入动画。不幸的是,当您将鼠标悬停时,div会恢复为原始大小。我希望div能够顺利恢复到原始大小。我尝试了Transition属性,但它不起作用,并且我怀疑它还是会干扰动画。
以下是我用于实验的完整代码(带有嵌入式CSS代码的自足html):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Post with edit/delete buttons experiment</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr"
crossorigin="anonymous">
<style>
html,
body {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.post-div {
height: 500px;
width: 500px;
border: thin solid lightgrey;
border-radius: 10px;
background-image: linear-gradient(to bottom right, white, whitesmoke);
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.post-div .edit-button.animated-button {
position: absolute;
top: -25px;
right: 75px;
background-image: linear-gradient(to bottom right, white, #0099ff);
}
.post-div .delete-button.animated-button {
position: absolute;
top: -25px;
right: 30px;
background-image: linear-gradient(to bottom right, white, #c00000);
}
.post-div .animated-button {
height: 35px;
width: 35px;
border: none;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
transition: animation 0.1s;
}
.post-div .animated-button:hover {
animation: button-hover 0.5s forwards ease-out;
}
.post-div .animated-button {
color: white;
}
.post-div p {
font-size: 40px;
}
@keyframes button-hover {
0% {
transform: scale(1);
}
70% {
transform: scale(1.4);
}
100% {
transform: scale(1.3);
}
}
</style>
</head>
<body>
<div class="post-div">
<div class="edit-button animated-button "><i class="far fa-edit"></i></div>
<div class="delete-button animated-button"><i class="fas fa-ban"></i></div>
<p>This is a very intesting post</p>
</div>
</body>
</html>
答案 0 :(得分:1)
我添加了动画按钮悬停
<div>
<full-menu :menus="yourMenuListAsDataOrProps"></full-menu>
</div>`
答案 1 :(得分:1)
您可以更轻松地做到这一点:
.animated-button {
transition: transform .5s ease-out;
}
.animated-button:hover {
transform: scale(1.3);
}
您无需制作多个关键帧动画,css将为您处理所有动画。