Html CSS字体颜色没有改变

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

CSS Font color not changing

htmlcss

提问by Javeria Habib

I am making a php/mysql site and have to make a search panel:

我正在制作一个 php/mysql 站点并且必须制作一个搜索面板:

The CSS Code is:

CSS代码是:

#search{
    color: #c02537;
    width:80%;
    margin: 20px auto;
    padding: 20px 20px;
    background: rgba(197,101,29,0.6);
    border-radius: 0 15px 0 15px;
    -moz-border-radius: 0 15px 0 15px;
    -webkit-border-radius: 0 15px 0 15px;
}
#searchf{
    margin:0 auto;
    width: 80%;
}

Corresponding HTML is:

对应的 HTML 是:

<div id="search">
<form method="post" action="index.php" name="search" id="searchf">  
    <table>
    <tr>
        <td>Food Category: <input type="text" name="food_category" id="searchfc"/> </td>
        <td>City: <input type="text" name="city" id="searchfc"/> </td>
    </tr>
    </table>    
</form>
</div>

The CSS fill is applying the margins, padding and border attributes but not the color.

CSS 填充应用了边距、填充和边框属性,但不应用颜色。

I have no idea why it is not working. Anybody have clues?

我不知道为什么它不起作用。有人有线索吗?

采纳答案by Pranav ?

The table's tdcolor might be overriding the color property of #search. Try this to specifically color the td's

表格的td颜色可能会覆盖 的颜色属性#search。试试这个来专门着色td's

#search table td {
    color: #c02537;
}

If you want to change the color of the input elements, try this :

如果要更改输入元素的颜色,请尝试以下操作:

#search table td input {
    color: #c02537;
}

Working DEMO

工作演示

回答by torp3d0

Have you tried this?

你试过这个吗?

color: #c02537 !important;

回答by Surinder ツ

You can use inheritance in css insted of using !important:

您可以在 css insted 中使用继承!important

#search table td {
    color: #c02537;
}

回答by Sigar Dave

Try using:

尝试使用:

color: #c02537 !Important;

If its not solve your issue then that means this color attribute is overwrite by your default link color.

如果它不能解决您的问题,则意味着此颜色属性将被您的默认链接颜色覆盖。

Use Browser Plugins like Firefox FireBug and verify that which Css styles are applied and which style is overwriting your color.

使用 Firefox FireBug 等浏览器插件并验证应用了哪些 Css 样式以及哪种样式覆盖了您的颜色。

Hope this helps

希望这可以帮助