gpt4 book ai didi

css - 从原点悬停时触发 translateY()

转载 作者:行者123 更新时间:2023-11-28 00:45:57 25 4
gpt4 key购买 nike

是否可以在按钮底部移动光标时无限期不触发动画?

这是它的样子 -- gifcodepen

.container {
padding: 1rem;
}

.container .here {
text-decoration: none;
color: white;
background: darkgreen;
display: inline-block;
margin: 2rem;
padding: 1rem;
transition: all .1s;
}

.container .here:hover {
transform: translateY(-1.5rem) scale(1.5);
}
<div class="container">
<div class="here">hover here</div>
</div>

最佳答案

通过添加伪元素使底部的按钮变大,您将避免闪烁:

.container {
padding: 1rem;
}

.container .here {
text-decoration: none;
color: white;
background: darkgreen;
display: inline-block;
margin: 2rem;
padding: 1rem;
transition: all .1s;
position:relative;
}
.container .here:before {
content:"";
position:absolute;
top:100%;
left:0;
right:0;
}

.container .here:hover {
transform: translateY(-1.5rem) scale(1.5);
}
.container .here:hover:before {
height:1.5rem;
}
<div class="container">
<div class="here">hover here</div>
</div>

关于css - 从原点悬停时触发 translateY(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53533387/

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