Html 改变按钮的颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34240949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 18:38:27  来源:igfitidea点击:

Changing the colour of a button

htmlcssbuttoncolors

提问by user2950895

I'm having problems in order to change the colour of this button. This is the code:

我在更改此按钮的颜色时遇到了问题。这是代码:

<div class = "Petrol">
   <a href="PayMethod.php"><button class="btn btn-default btn-lg" type="button"><span class="Text">Petrol<br><small>(Hi-Grade)</small></span></button>
   </a>
</div>

Can you please help me?

你能帮我么?

回答by Ashish

if you need to change the color of the button do this:

如果您需要更改按钮的颜色,请执行以下操作:

 .btn {
      background-color:blue;
    }

if you need to change the text inside the color of the button

如果您需要更改按钮颜色内的文本

.btn {
      color:red;
    }

回答by musafar006

Assuming by the classes you used, I think you are using Bootstrap. Bootstrap provide pre-defined classes to change bg color of buttons. Replace btn-defaultby any of the following to get a different color. btn-primary, btn-success, btn-info, btn-warning, btn-danger, and btn-link. Take a look at the docs.

假设您使用的类,我认为您正在使用 Bootstrap。Bootstrap 提供预定义的类来更改按钮的 bg 颜色。替换btn-default为以下任何一种以获得不同的颜色。btn-primarybtn-successbtn-infobtn-warningbtn-danger,和btn-link。看看文档

You could also apply a custom class btn-customand style it.

您还可以应用自定义类btn-custom并为其设置样式。

.btn-custom {
  background: #ff0; /* use your color here */
}

回答by Antonio Smoljan

Straightfoward way works fine

直截了当的方式工作正常

.btn {
  color:blue;
} 

Example

例子