悬停时的CSS3颜色过渡,但点击后立即变色

时间:2014-11-28 20:57:28

标签: css css3

我已对页面进行了编码,以便当光标悬停在链接上时,它会逐渐通过CSS3更改颜色。我想要它,这样当它被点击时,它会立即变为另一种颜色。我怎么能这样做?

.menuButton {
    color: #888;
}
.menuButton:hover {
    color: black;
    -webkit-transition: color 0.7s ease-in;
    -moz-transition: color 0.7s ease-in;
    -o-transition: color 0.7s ease-in;
    -ms-transition: color 0.7s ease-in;
    transition: color 0.7s ease-in;
}
.menuButton:active {
    color: #880000;
}    

1 个答案:

答案 0 :(得分:3)

使用transition-property:none;

.menuButton:active {
    color: #880000;
    -webkit-transition-property: none;
    -moz-transition-property: none;
    -o-transition-property: none;
    -ms-transition-property: none;
    transition-property: none;
}