当我将鼠标悬停在按钮上时,我被要求有一个圆形的“增长”效果。

请参阅此链接的参考,我需要的按钮如何工作。http://demo1.wpopal.com/corpec/home-4/
目前,我已经在悬停时实现了“不是这个”的效果;尽管我的雇主希望这个效果有一点舍入。
我在"not this“按钮上使用了下面的css来达到增长的效果,尽管我需要将边缘变圆。
.Custom-Button a {
position: relative;
display: inline-block;
padding: 15px 70px;
border: 1px solid #fdc900 !important;
color: white;
font-size: 30px;
font-family: arial;
background-image: linear-gradient(#fdc900, #fdc900);
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: 0% 100%;
transition: background-size .5s, color .5s;
}
.Custom-Button a:hover {
background-size: 100% 100%;
color: black;
}<div class="Custom-Button">
<a href="#">BUTTON</a>
</div>
我只被允许使用CSS来实现下面的效果,并且已经花了一天的时间来尝试让它工作。
发布于 2019-05-23 01:31:45
将伪元素应用于按钮解算!希望这对你有所帮助!
.Custom-Button{
position: relative;
display: inline-block;
padding: 15px 70px;
border: 1px solid #fdc900 !important;
color: white;
font-size: 30px;
font-family: arial;
border-radius:50px;
position:relative;
}
.Custom-Button a{
z-index:99;
text-decoration:none;
transition:color 1s;
}
.Custom-Button:hover:after{
width:100%;
}
.Custom-Button:hover a{
color:black;
}
.Custom-Button:after{
width:0%;
transition: width 1s;
height:100%;
z-index:-1;
content:"";
position:absolute;
border-radius:50px;
top:0;
left:50%;
transform:translateX(-50%);
background-image: linear-gradient(#fdc900, #fdc900);
}<div class="Custom-Button">
<a href="#">BUTTON</a>
</div>
发布于 2019-05-23 01:35:42
您可以通过组合z-index以及基础元素的位置和宽度的过渡来实现此效果:
悬停时,filler的子级将从
position: absolute; left: 50%;至
position: absolute; left: 0;同时还可以从width: 0;调整到width: 100%;
这将会给你带来“从中间成长”的理想效果。
此外,还需要将边界半径应用于正在增长的元素
a {
position: relative;
display: inline-block;
padding: 15px 70px;
border: 1px solid #fdc900 !important;
color: black;
font-size: 30px;
font-family: arial;
border-radius: 32px;
}
.text {
position: relative;
z-index: 2000;
}
.filler {
position: absolute;
z-index: 1000;
top: 0;
left: 50%;
width: 0;
height: 100%;
border-radius: 32px;
/* half of <a> height */
background-color: #fdc900;
transition: width .5s, color .5s, left .5s;
}
a:hover .filler {
z-index: 500;
width: 100%;
left: 0;
color: black;
}
a:hover .text {
color: white;
}<a href="#">
<div class="text">
BUTTON
</div>
<div class="filler">
</div>
</a>
https://stackoverflow.com/questions/56261613
复制相似问题