我希望按钮上链接的颜色在悬停时为黄色,但似乎不起作用,因为在悬停时,文本仍为白色。
的HTML:
<button class="headerbutton headerbutton-style">
<a href="#">Learn More</a>
</button>
CSS:
a, .headerbutton {
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
}
.headerbutton {
font-family: "Open Sans";
font-weight: 400;
font-size: 12pt;
border-radius: 20px;
cursor: pointer;
padding: 15px 25px;
}
.headerbutton-style {
background-color: #FAD059;
border: 2px solid white;
}
.headerbutton-style:hover {
background-color: white;
color: #FAD05A;
}
.headerbutton a {
color: white;
text-decoration: none;
}
.headerbutton a:hover {
color: #FAD05A;
text-decoration: none;
}
最佳答案
更改此规则
.headerbutton a:hover {
color: #FAD05A;
text-decoration: none;
}
对此
.headerbutton:hover a {
color: #FAD05A;
text-decoration: none;
}
然后它将起作用。看到这个http://codepen.io/anon/pen/RaLwEB
关于css - 悬停时按钮颜色不变,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36340100/