textarea 不继承父元素的 css 颜色
textarea doesn't inherit css color form parent element
我在 div 中有一个文本区域。 div css 设置颜色,但文本区域似乎对此没有反应。
这是正确的行为吗?
我怎样才能让颜色 属性 从 div 应用到文本区域?
.c1 {
color: red;
}
<div class="c1">
An now for something completly different :<br/>
<textarea>
the news : spam spam spam spam spam
</textarea>
</div>
请尝试以下CSS。
.c1,textarea.classname {color:red;}
试试这个CSS代码
.c1,textarea {
color:red;
}
Textarea 将不会继承,除非您将其标记为
.c1 textarea{
color:inherit;
}
因此您可以为 div
子字段和 textarea
字段应用颜色。如果我没记错的话 input
标签也不会继承 default
的颜色
浏览器为输入、按钮等提供默认样式...
所以 Textarea
设置了 color:initial
。您需要在代码中指定 Textarea
.
的颜色
.c1,
textarea{
color:red;
}
因为textarea有浏览器应用的默认样式所以继承不起作用:
您需要为文本区域指定颜色或使用 inherit
获取 div
的颜色
.c1 {
color: red;
}
textarea {
color:inherit;
}
<div class="c1">
An now for something completly different :<br/>
<textarea>
the news : spam spam spam spam spam
</textarea>
</div>
我在 div 中有一个文本区域。 div css 设置颜色,但文本区域似乎对此没有反应。
这是正确的行为吗? 我怎样才能让颜色 属性 从 div 应用到文本区域?
.c1 {
color: red;
}
<div class="c1">
An now for something completly different :<br/>
<textarea>
the news : spam spam spam spam spam
</textarea>
</div>
请尝试以下CSS。
.c1,textarea.classname {color:red;}
试试这个CSS代码
.c1,textarea {
color:red;
}
Textarea 将不会继承,除非您将其标记为
.c1 textarea{
color:inherit;
}
因此您可以为 div
子字段和 textarea
字段应用颜色。如果我没记错的话 input
标签也不会继承 default
浏览器为输入、按钮等提供默认样式...
所以 Textarea
设置了 color:initial
。您需要在代码中指定 Textarea
.
.c1,
textarea{
color:red;
}
因为textarea有浏览器应用的默认样式所以继承不起作用:
您需要为文本区域指定颜色或使用 inherit
获取 div
.c1 {
color: red;
}
textarea {
color:inherit;
}
<div class="c1">
An now for something completly different :<br/>
<textarea>
the news : spam spam spam spam spam
</textarea>
</div>