Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.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
Css 不属于第n个子选择器,不在sass中工作_Css_Angular_Sass - Fatal编程技术网

Css 不属于第n个子选择器,不在sass中工作

Css 不属于第n个子选择器,不在sass中工作,css,angular,sass,Css,Angular,Sass,我正在尝试将某些样式应用于列表中除第一个子项之外的所有项。我认为我正确地设置了sass,但是目前尚未应用该样式 html 你可以通过所有背景为蓝色的物品和第一个背景为白色的物品或任何你的背景来实现这一点 <div class="list"> <div *ngFor="let item of data; let i=index" [class.first]="i === 0"> <input class="radio" name="radio" type="

我正在尝试将某些样式应用于列表中除第一个子项之外的所有项。我认为我正确地设置了sass,但是目前尚未应用该样式

html


你可以通过所有背景为蓝色的物品和第一个背景为白色的物品或任何你的背景来实现这一点

<div class="list">
<div *ngFor="let item of data; let i=index"  [class.first]="i === 0">
    <input class="radio" name="radio" type="radio" />
<label for="radio1" class="lbl">{{item.name}}</label>
我假设您的数据如下:

 data = [
    {name: "car"},
    {name: "truck"},
    {name: "bike"}
  ]
如果您的意思是选择除第一个之外的所有.list项,CSS将如下所示:

.list-item:not(:nth-of-type(1))::before {
    content: '';
    background-color:blue;
}
因为您使用的是pseudo-element::before,所以可能需要使用content:来指定一些内容,否则背景色将没有效果

label {
  background-color:blue;
}
.first label {
  background-color: #fff;
}
 data = [
    {name: "car"},
    {name: "truck"},
    {name: "bike"}
  ]
.list-item:not(:nth-of-type(1))::before {
    content: '';
    background-color:blue;
}