【发布时间】:2022-10-06 10:09:33
【问题描述】:
任何输入都会很棒,因为我刚刚开始处理 css3 keyframe 动画和过渡。我制作了一个网格并使用网格模板区域分配了这些网格项目。
.admin-grid {
background: url(../media/rocks.jpg) no-repeat center center fixed;
background-size: cover;
display: grid;
height: 100vh;
background: linear_gradient(black,white);
grid-template-areas: \"a a a\"
\"b c d\"
\"e e e\";
}
.grid-item {
margin: 1rem;
display: grid;
justify-content: center;
align-items: center;
border-radius: 5rem;
color: white;
box-shadow: -3px 5px #a52700;
background: linear-gradient(45deg,rgb(48, 87, 189),black,rgb(180, 59, 59));
animation: load-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 1 forwards;
}
.grid-item:hover {
animation: change_gradient 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) ;
}
这将是我的关键帧。
@keyframes load-in {
0% {
position: relative;
opacity: 0;
padding: 0.5rem;
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
position: relative;
opacity: 1;
transform: scale(1);
padding: 1rem;
}
}
@keyframes change_gradient {
to {
/*not yet finished*/
}
}
每次我将鼠标悬停在我的任何网格项目上,然后从网格项目中移除光标时,加载动画都会再次开始。我只打算让这个动画在页面加载时发生一次。我不知道如何做到这一点。
简而言之:如何仅在页面加载时而不是在悬停状态关闭时运行加载动画?
标签: html css css-animations