【问题标题】:How to set text color in submit button?如何在提交按钮中设置文本颜色?
【发布时间】:2012-09-10 08:53:01
【问题描述】:

我尝试更改提交按钮类型中文本的颜色,但不知道为什么无法更改。

.button {
  width: 105px;
  height: 20px;
  background-image: url('tiny.gif');
  line-height: 20px;
  padding-bottom: 2px;
  vertical-align: middle;
  font-family: "Lucida Grande", Geneva, Verdana, Arial, Helvetica, sans-serif;
  font-size: 13px;
  <!--font-weight: bold;
  -->text-transform: none;
  border: 1px solid transparent;
}

.button:hover {
  background-image: url('tiny_.gif');
}
&lt;input type="submit" value="Fetch" class="button" /&gt;

我在尝试更改提交按钮的颜色时遇到问题。

【问题讨论】:

  • “遇到问题”——这对我们毫无帮助。你期望会发生什么?实际发生了什么?您的控制台日志中是否有任何消息?我将background-color: red 添加到您的:hover 中,当我将鼠标悬停时按钮改变了颜色。也许tiny_.gif 没有加载?

标签: html css button submit-button


【解决方案1】:

.button
{
    font-size: 13px;
    color:green;
}
&lt;input type="submit" value="Fetch" class="button"/&gt;

【讨论】:

    【解决方案2】:

    你试试这个:

    <input type="submit" style="font-face: 'Comic Sans MS'; font-size: larger; color: teal; background-color: #FFFFC0; border: 3pt ridge lightgrey" value=" Send Me! ">
    

    【讨论】:

    • 当外部样式表可用时,内联样式不是一个好主意。
    • 这对于糟糕的 css-ed 页面和测试页面将如何呈现是非常好的主意。对于完整的 css 页面,应将其移至外部 css 文件。
    【解决方案3】:
    <button id="fwdbtn" style="color:red">Submit</button> 
    

    【讨论】:

      【解决方案4】:

      使用这个 CSS:

      color: red;
      

      就是这样。

      【讨论】:

        【解决方案5】:
        <input type = "button" style ="background-color:green"/>
        

        【讨论】:

        • OP 想要更改提交的文本颜色,而您为他提供了内联样式(=不好的做法)更改按钮的背景颜色。这没有多大帮助......
        【解决方案6】:
        .btn{
            font-size: 20px;
            color:black;
        }
        

        【讨论】:

        • 你能解释一下你的解决方案吗,只有代码有点难以正确理解答案
        • 虽然此代码可能会回答问题,但提供有关它如何和/或为什么解决问题的额外上下文将提高​​答案的长期价值。
        猜你喜欢
        • 2023-03-21
        • 2015-12-07
        • 2015-05-11
        • 2011-09-12
        • 1970-01-01
        • 1970-01-01
        • 2013-08-30
        • 2011-11-23
        • 1970-01-01
        相关资源
        最近更新 更多