简体   繁体   English

CSS 属性选择器,后面有另一个选择器

[英]CSS attribute selector with another selector after it

I am trying to do something like this in Angular:我正在尝试在 Angular 中做这样的事情:

css css

header-wrap[icon="taco"] icon-element {margin: 1rem;}

HTML HTML

<header-wrap icon="taco">
 <icon-element></icon-element>
</header-wrap>

But it will not work.但它不会工作。 Are attribute selectors "end of the road" selectors?属性选择器是“路的尽头”选择器吗? Meaning you cannot select things after it?意思是你不能选择它之后的东西? The strange part is that when I use document.querySelectorAll in chrome inspector it returns the element I want, but any attempt to write a style for this case fails.奇怪的是,当我在 chrome Inspector 中使用 document.querySelectorAll 时,它返回我想要的元素,但是为这种情况编写样式的任何尝试都失败了。

I tested your code and it works on my side!我测试了你的代码,它对我有用! Your CSS code is right and it targets well the element you want.你的 CSS 代码是正确的,它很好地针对你想要的元素。

The problem would apparently be that your tag icon-element is empty.问题显然是你的标签图标元素是空的。 When I added some text in it the CSS changes occurred.当我在其中添加一些文本时,CSS 发生了变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM