How to change the button color when it is active using bootstrap?

后端 未结 3 1176
礼貌的吻别
礼貌的吻别 2020-12-17 09:56

I am using bootstrap 3. I want to change button color when I click on button.I mean button should be in different color when it is selected. How can I do this using css?

3条回答
  •  醉梦人生
    2020-12-17 10:34

    CSS has different pseudo selector by which you can achieve such effect. In your case you can use

    :active : if you want background color only when the button is clicked and don't want to persist.

    :focus: if you want background color untill the focus is on the button.

    button:active{
        background:olive;
    }
    

    and

    button:focus{
        background:olive;
    }
    

    JsFiddle Example

    P.S.: Please don't give the number in Id attribute of html elements.

提交回复
热议问题