Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为所有子体应用样式,链接无效除外_Html_Css - Fatal编程技术网

Html 为所有子体应用样式,链接无效除外

Html 为所有子体应用样式,链接无效除外,html,css,Html,Css,我有一个场景可以将颜色应用于除锚定标记 本文中的示例文本 没有将颜色样式显式应用于锚元素 color的默认值是inherit,因此,即使您已从选择器中排除锚定,它仍将从其父级div.wrapper继承颜色 供参考;你的检查员实际上说: 因为锚不是.text的子对象 看看这个 <div class="texts"> <div class="wrapper"> sample text in this </div> <div class

我有一个场景可以将颜色应用于除锚定标记

本文中的示例文本

没有将
颜色
样式显式应用于锚元素

color
的默认值是
inherit
,因此,即使您已从选择器中排除锚定,它仍将从其父级
div.wrapper
继承颜色

供参考;你的检查员实际上说:


因为锚不是.text的子对象

看看这个

<div class="texts">
  <div class="wrapper">
    sample text in this
  </div>
    <div class="wrapper">
    sample text in this
  </div>
    <div class="wrapper">
    sample text in this
  </div>
    <div class="wrapper">
    sample text in this
  </div>
    <div class="wrapper">
    <a href="#">TEST</a>
  </div>
    <div class="wrapper">
    sample text in this
  </div>
  <a href="#">TEST2</a>
</div>

.texts *:not(a) {
  color: red;
  font-size: 20px;
}

本文中的示例文本
本文中的示例文本
本文中的示例文本
本文中的示例文本
本文中的示例文本
.文本*:非(a){
颜色:红色;
字体大小:20px;
}

css未应用于test2子锚点:)

是否有解决方案?因为当我将此样式转换为内联样式时,红色将应用于锚定标记这是设计的,所以这本身并不是问题。您可以将锚定标记的
颜色
样式更改为任何您想要阻止继承的内容,例如
.text.wrapper a{color:green;}
。我想要链接的默认颜色。有什么方法可以阻止锚定标记被应用于样式吗?@melvin-您拥有链接的默认颜色。您可以看出这是因为浏览器样式表规则(带有选择器
a:-webkit any link
)覆盖了继承的颜色(被划掉)。@George感谢您的时间OK。但当我将此样式转换为内联样式时,红色将作为内联样式应用于锚定,因为在内联样式中可以直接添加样式。您不能选择特定的元素我已经添加了
:not()
,那么为什么它的目标是
,当转换为inlineHi-Melvin时,您不能以inline样式使用此选择器。这就是为什么这可以帮助“儿童元素(直接和间接)”-儿童是儿童,没有所谓的“间接”儿童。您正在寻找的术语是子女和后代。@Quentin Ok。如何修改我的要求?将短语“子元素(直接和间接)”替换为“子元素”