如何更改 html 表格中的字体颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44248294/
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 14:42:51  来源:igfitidea点击:

How do I change the font color in an html table?

htmlfontscolors

提问by ttom

How do I change the font color in an html table?

如何更改 html 表格中的字体颜色?

<table>
<tbody>
<tr>
<td>
<select name="test">
<option value="Basic">Basic : .00 USD - yearly</option>
<option value="Sustaining">Sustaining : .00 USD - yearly</option>
<option value="Supporting">Supporting : 0.00 USD - yearly</option>
</select>
</td>
</tr>
</tbody>
</table>

I have tried

我试过了

<span style="color: #0000ff;"> 
</span> 

in multiple locations ... which doesn't work.

在多个位置......这不起作用。

回答by Muhammad Afaq Riaz

<table>
<tbody>
<tr>
<td>
<select name="test" style="color: red;">
<option value="Basic">Basic : .00 USD - yearly</option>
<option value="Sustaining">Sustaining : .00 USD - yearly</option>
<option value="Supporting">Supporting : 0.00 USD - yearly</option>
</select>
</td>
</tr>
</tbody>
</table>

回答by TomServo

Something like this, if want to go old-school.

像这样的东西,如果想要去老派。

<font color="blue">Sustaining : .00 USD - yearly</font>

Though a more modern approach would be to use a css style:

虽然更现代的方法是使用 css 样式:

<td style="color:#0000ff">Sustaining : .00 USD - yearly</td>

There are of course even more general ways to do it.

当然还有更通用的方法来做到这一点。

回答by Yahya Essam

if you need to change specific option from the select menu you can do it like this

如果您需要从选择菜单中更改特定选项,您可以这样做

option[value="Basic"] {
  color:red;
 }

or you can change them all

或者你可以全部改变它们

select {
  color:red;
}

回答by tech2017

table td{
  color:#0000ff;
}

<table>
  <tbody>
    <tr>
    <td>
      <select name="test">
        <option value="Basic">Basic : .00 USD - yearly</option>
        <option value="Sustaining">Sustaining : .00 USD - yearly</option>
        <option value="Supporting">Supporting : 0.00 USD - yearly</option>
      </select>
    </td>
    </tr>
  </tbody>
</table>

回答by Idan Dagan

Try this:

尝试这个:

 <html>
    <head>
        <style>
            select {
              height: 30px;
              color: #0000ff;
            }
        </style>
    </head>
    <body>
        <table>
            <tbody>
                <tr>
                    <td>
                        <select name="test">
                            <option value="Basic">Basic : .00 USD - yearly</option>
                            <option value="Sustaining">Sustaining : .00 USD - yearly</option>
                            <option value="Supporting">Supporting : 0.00 USD - yearly</option>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>