gpt4 book ai didi

CSS:悬停过渡时按钮边框渐变反转

转载 作者:行者123 更新时间:2023-11-28 10:24:50 25 4
gpt4 key购买 nike

我正在设置此按钮转换,我发现我用于网络中其他按钮的效果与此按钮效果不佳。边框颜色在过渡时反转。

我必须使用渐变背景,因此无法更改它。

#button {
background: linear-gradient(#FFF,#FFF) padding-box, linear-gradient(to right, blue 0%, green 100%) border-box;
border: 3px solid transparent;
color: #000;
background-color: white;
border-radius: 25px;
margin-top: 60px;
margin-bottom: 0px;
font-weight: 600;
font-size: 14px;
padding: 7px 22px;
transition: all .5s ease;
margin-left: auto;
margin-right: auto;
display: block;
}

#button:hover{
background: linear-gradient(to right, blue 0%, green 100%);
border: 3px solid transparent;
color: #FFF;
transition: all .5s ease;
transition-property: all;
transition-duration: 0.5s;
transition-timing-function: ease;
transition-delay: 0s;
}
<button id="button"> BUTTON </button>

最佳答案

你的悬停/焦点渐变应该是border-box:

background: linear-gradient(to right, blue 0%, green 100%) border-box;

.myb {
display: inline-block;
cursor: pointer;
background: linear-gradient(#FFF, #FFF) padding-box, linear-gradient(to right, blue 0%, green 100%) border-box;
border: 3px solid transparent;
color: #000;
background-color: white;
border-radius: 25px;
margin-top: 60px;
margin-bottom: 0px;
font-weight: 600;
font-size: 14px;
padding: 7px 22px;
transition: all .5s ease;
margin-left: auto;
margin-right: auto;
}

.myb:hover,
.myb:focus {
background: linear-gradient(to right, blue 0%, green 100%) border-box;
border: 3px solid transparent;
color: #FFF;
transition: all .5s ease;
transition-property: all;
transition-duration: 0.5s;
transition-timing-function: ease;
transition-delay: 0s;
}
<div class="myb">
Button
</div>

同时在 JSFiddle .

关于CSS:悬停过渡时按钮边框渐变反转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55845177/

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