悬停时无法更改元素的边框颜色
Can't change element's border colour on hover
我正在尝试在用户将鼠标悬停在按钮上时更改三角形的颜色。
我尝试将样式应用到按钮的悬停子元素上,但没有成功。
如何让三角形在按钮悬停时使用普通按钮的背景颜色改变颜色。
我的代码:
#contact-form .submit {
background: none repeat scroll 0 0 #3f3f3f;
display: block;
margin-top: 30px;
padding: 16px 40px;
width: 115px;
}
.contact-submit a {
color: #222;
font-weight: normal;
}
#contact-form > .contact-submit > .hvr-bubble-float-top {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-property: transform;
transition-property: transform;
top: 0;
}
#contact-form > .contact-submit > .hvr-bubble-float-top:before {
position: absolute;
z-index: -1;
content: '';
left: calc(50% - 10px);
top: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #666 transparent;
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-property: transform;
transition-property: transform;
}
#contact-form > .contact-submit > .hvr-bubble-float-top:hover, #contact-form > .contact-submit > .hvr-bubble-float-top:focus, #contact-form > .contact-submit > .hvr-bubble-float-top:active {
-webkit-transform: translateY(10px);
transform: translateY(10px);
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
display: inline-block;
background-color: #666;
border-color: transparent transparent #666 transparent !important;
}
#contact-form > .contact-submit > .hvr-bubble-float-top:hover:before, #contact-form > .contact-submit > .hvr-bubble-float-top:focus:before, #contact-form > .contact-submit > .hvr-bubble-float-top:active:before {
-webkit-transform: translateY(-10px);
transform: translateY(-10px);
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
position: absolute;
z-index: 5000;
}
<p class="contact-submit">
<a id="contact-submit" class="submit hvr-bubble-float-top" href="#">SEND MESSAGE</a>
</p>
CSS 尝试转换的唯一 属性 是 transform
,因为此代码:
transition-property: transform;
您发布的代码中有很多内容,但首先要尝试将其更改为:
transition-property: transform, border-color;
再试一次。
为 .hvr-bubble-float-top:hover:before
更新 border-bottom-color
。使用您的样式作为基础:
#contact-form > .contact-submit > .hvr-bubble-float-top:hover:before,
#contact-form > .contact-submit > .hvr-bubble-float-top:focus:before,
#contact-form > .contact-submit > .hvr-bubble-float-top:active:before {
…
border-bottom-color: red;
}
我正在尝试在用户将鼠标悬停在按钮上时更改三角形的颜色。
我尝试将样式应用到按钮的悬停子元素上,但没有成功。
如何让三角形在按钮悬停时使用普通按钮的背景颜色改变颜色。
我的代码:
#contact-form .submit {
background: none repeat scroll 0 0 #3f3f3f;
display: block;
margin-top: 30px;
padding: 16px 40px;
width: 115px;
}
.contact-submit a {
color: #222;
font-weight: normal;
}
#contact-form > .contact-submit > .hvr-bubble-float-top {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-property: transform;
transition-property: transform;
top: 0;
}
#contact-form > .contact-submit > .hvr-bubble-float-top:before {
position: absolute;
z-index: -1;
content: '';
left: calc(50% - 10px);
top: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #666 transparent;
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-property: transform;
transition-property: transform;
}
#contact-form > .contact-submit > .hvr-bubble-float-top:hover, #contact-form > .contact-submit > .hvr-bubble-float-top:focus, #contact-form > .contact-submit > .hvr-bubble-float-top:active {
-webkit-transform: translateY(10px);
transform: translateY(10px);
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
display: inline-block;
background-color: #666;
border-color: transparent transparent #666 transparent !important;
}
#contact-form > .contact-submit > .hvr-bubble-float-top:hover:before, #contact-form > .contact-submit > .hvr-bubble-float-top:focus:before, #contact-form > .contact-submit > .hvr-bubble-float-top:active:before {
-webkit-transform: translateY(-10px);
transform: translateY(-10px);
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
position: absolute;
z-index: 5000;
}
<p class="contact-submit">
<a id="contact-submit" class="submit hvr-bubble-float-top" href="#">SEND MESSAGE</a>
</p>
CSS 尝试转换的唯一 属性 是 transform
,因为此代码:
transition-property: transform;
您发布的代码中有很多内容,但首先要尝试将其更改为:
transition-property: transform, border-color;
再试一次。
为 .hvr-bubble-float-top:hover:before
更新 border-bottom-color
。使用您的样式作为基础:
#contact-form > .contact-submit > .hvr-bubble-float-top:hover:before,
#contact-form > .contact-submit > .hvr-bubble-float-top:focus:before,
#contact-form > .contact-submit > .hvr-bubble-float-top:active:before {
…
border-bottom-color: red;
}