【发布时间】:2021-03-24 09:32:07
【问题描述】:
将鼠标悬停在按钮 #2 上时,如何使黑色边框的过渡更平滑?
目前,将鼠标悬停在按钮 #2 上时会稍有延迟。 有没有更好的方法?
我想让圆形按钮的边框快速填充。目前,它有点滞后,我觉得这会分散注意力。
谢谢!
.btn {
width: 130px;
height: 50px;
border: none;
margin: 4rem;
}
.btn2 {
position: relative;
overflow: hidden;
transition: height .5s;
}
.btn2::after {
content:"";
display: block;
background-color: black;
width: 40px;
height: 40px;
border-radius: 50%;
position: absolute;
top:50px;
left:50px;
opacity: .2;
transition: top 1.2s ease-out;
}
.btn2::before {
content:"";
display: block;
background-color: black;
width: 25px;
height: 25px;
border-radius: 50%;
position: absolute;
top:-50px;
left:15px;
opacity: .2;
transition: top 1.2s ease-out;
}
.btn2:hover::before{
position: absolute;
top:34px
}
.btn2:hover::after{
position: absolute;
top:70px
}
.btn2:hover {
height: 130px;
border-radius: 50%;
animation:circle 4s ease;
}
@keyframes circle {
0%{ border:none}
10%{border-top:2px solid}
25%{border-right:2px solid}
45%{border-bottom:2px solid}
65%{border-left:2px solid}
85%{border:2px solid}
100%{border:2px solid}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A Great Demo on CodePen</title>
</head>
<body>
<div class="wrap">
<button class="btn btn2">button 2 !!</button>
</div>
</body>
</html>
【问题讨论】:
-
请澄清您的具体问题或添加其他详细信息以准确突出您的需要。正如目前所写的那样,很难准确地说出你在问什么。
-
寻求代码帮助的问题必须包括在问题本身中重现它所需的最短代码,最好是在堆栈片段中。尽管您提供了一个链接,但如果它变得无效,那么您的问题对于未来遇到同样问题的其他 SO 用户将毫无价值。见Something in my website/example doesn't work can I just paste a link。
-
你好!我建议您阅读文章How do I ask a good question?。它将帮助您获得最佳答案!
-
我是对的,你想要的效果是让边框平滑地出现,一次一点点从顶部开始并循环(而不是在任何地方从 0 到 2px 均匀增长)一次)?
-
嗨,海沃氏,我希望它看起来像有人在画一个圆圈。像border-top >border-right >border-bottom >border-bottom平滑出现,从代码中可以看到border-top >stop a little bit >border-right >stop a little bit >border-bottom >stop a一点点>边框底部。谢谢。
标签: css animation css-transitions smoothing keyframe