gpt4 book ai didi

html - CSS 在不同事件期间多次转换为同一元素

转载 作者:太空狗 更新时间:2023-10-29 16:03:47 25 4
gpt4 key购买 nike

我有一组链接标 checkout 现在使用 translate3D 加载的页面上。这工作得很好。但我需要链接标签来缩放它的悬停。哪个不能直接工作。


有没有办法只用 CSS 实现它?这是代码:

.linkblock {
margin: 20% 0;
}

.hlink {
width: 12%;
height: 60px;
opacity: 0;
padding: 0 10px;
background: rgba(0, 0, 0, 0.3);
display: inline-block;
text-align: center;
color: rgba(0, 0, 0, 0.6);
transition: all 0.5s ease;
}

.hlink:hover {
transform: translate(0px, -20px);
color: red;
background: rgba(0, 0, 0, 0.6)
}

@keyframes fadeInUp {
from {
opacity: 0;
transform: translate3d(0, 100%, 0);
}
to {
opacity: 1;
transform: translate3d(0, 0, 0);
}
}

.fadeInUp {
animation: fadeInUp 0.3s ease-in both;
}

.linkblock a:nth-child(1) {
animation-delay: 1.0s;
}

.linkblock a:nth-child(2) {
animation-delay: 1.1s;
}

.linkblock a:nth-child(3) {
animation-delay: 1.2s;
}

.linkblock a:nth-child(4) {
animation-delay: 1.3s;
}

.linkblock a:nth-child(5) {
animation-delay: 1.4s;
}

.linkblock a:nth-child(6) {
animation-delay: 1.5s;
}

.linkblock a:nth-child(7) {
animation-delay: 1.6s;
}

.linkblock a:nth-child(8) {
animation-delay: 1.7s;
}
<div class="linkblock">
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>

</div>

最佳答案

问题是 both 的使用允许您保持动画的最后状态,因此动画内部的变换将覆盖悬停时永远不会被激活的变换。

您可以将您的动画拆分为 2 个动画并使用 both 或仅使用 opacityforwards 并且您将能够在之后进行过渡动画完成。

.linkblock {
margin: 20% 0;
}

.hlink {
width: 12%;
height: 60px;
padding: 0 10px;
background: rgba(0, 0, 0, 0.3);
display: inline-block;
text-align: center;
color: rgba(0, 0, 0, 0.6);
transition: all 0.5s ease;
opacity:0;
}

.hlink:hover {
transform: translate(0px, -20px) scale(1.2);
color: red;
background: rgba(0, 0, 0, 0.6)
}

@keyframes fadeInUp {
from {
transform: translate3d(0, 100%, 0);
}
}
@keyframes show {
to {
opacity:1;
}
}

.fadeInUp {
animation: fadeInUp 0.3s ease-in,
show 0.3s ease-in forwards;
}

.linkblock a:nth-child(1) {
animation-delay: 1.0s;
}

.linkblock a:nth-child(2) {
animation-delay: 1.1s;
}

.linkblock a:nth-child(3) {
animation-delay: 1.2s;
}

.linkblock a:nth-child(4) {
animation-delay: 1.3s;
}

.linkblock a:nth-child(5) {
animation-delay: 1.4s;
}

.linkblock a:nth-child(6) {
animation-delay: 1.5s;
}

.linkblock a:nth-child(7) {
animation-delay: 1.6s;
}

.linkblock a:nth-child(8) {
animation-delay: 1.7s;
}
<div class="linkblock">
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>
<a href="#" class="fadeInUp hlink">fsdfsdf</a>

</div>

关于html - CSS 在不同事件期间多次转换为同一元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53705049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com