本文介绍了当使用bootstrap激活时,如何更改按钮颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是bootstrap 3.当我点击按钮时,我想改变按钮的颜色。我的意思是当它被选择时,按钮应该是不同的颜色。我如何使用css?

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?

我的代码是:

<div class="col-sm-12" id="">
    <button type="submit" class="btn btn-warning" id="1">Button1</button>
    <button type="submit" class="btn btn-warning" id="2">Button2</button>
</div>


推荐答案

影响。在您的情况下,您可以使用

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

:focus :如果您想要背景颜色,直到焦点在按钮上。

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



button:active{
    background:olive;
}

button:focus{
    background:olive;
}

PS:请不要给出 Id html元素的属性。

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

这篇关于当使用bootstrap激活时,如何更改按钮颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:25
查看更多