如何在引导程序中按下按钮颜色?

时间:2015-11-04 20:43:38

标签: html css twitter-bootstrap

当有人按下该按钮时,我想在Bootstrap中声明一个不同的按钮颜色。我怎样才能做到这一点?这是我当前按钮的代码:

.comment-box .btn {
    background-color: rgb(38, 173, 228);
    color: white;
}

(P.S。:有人知道css-lib stackoverflow正在使用它的蓝色按钮吗?)

2 个答案:

答案 0 :(得分:0)

您想使用:active选择器:

 .comment-box .btn:active {
            background-color: rgb(38, 173, 228);
            color: white;
        } 

以下是其他选择者的参考:

/* unvisited link */
    a:link {
        color: green;
    }

    /* visited link */
    a:visited {
        color: green;
    }

    /* mouse over link */
    a:hover {
        color: red;
    }

    /* selected link */
    a:active {
        color: yellow;
    }

答案 1 :(得分:0)

您可以使用javascript使用onclick来计算按钮的点击次数,然后在每次点击时更改其颜色,您可以在数组中定义颜色。 数组中颜色的索引将对应于单击按钮的次数。