Sass SCSS中以下代码段中*=的含义
我是scss的新手。下面代码中*=的含义是什么Sass SCSS中以下代码段中*=的含义,sass,Sass,我是scss的新手。下面代码中*=的含义是什么 div[class*="SnackbarItem-contentRoot"] { width: 600px; &[class*="SnackbarItem-variantError"]{ background-color: $orange; color: $white; } } *=不是SCSS功能,它是CSS中使用的属性选择器 例如,这将选择
div[class*="SnackbarItem-contentRoot"] {
width: 600px;
&[class*="SnackbarItem-variantError"]{
background-color: $orange;
color: $white;
}
}
*=
不是SCSS功能,它是CSS中使用的属性选择器
例如,这将选择具有href属性的所有元素,该属性的值至少包含一次示例,并将字体大小应用于2em
a[href*=“示例”]{
字号:2em;
}
在我们的例子中,*=
意味着使用类获取所有div,该类的值至少包含一个出现的“SnackbarItem contentRoot”
然而,&
,一种由Sass发明的父选择器,用于嵌套选择器。
&[class*=“SnackbarItem varianterroom”]
表示获取所有div,其值至少包含一个出现的“SnackbarItem contentRoot”
您可以找到有关属性选择器的更多信息
> This is CSS Attribute Selector.
It is used to select all html elements whose Attribute or class Attribute is "className" or html Attribute name.
where * means 'All' and '=' match Attribute value.
e.g - it select all div whose className is 'SnackbarItem-contentRoot'
div[class*="SnackbarItem-contentRoot"] {
background: yellow;
width:600px;
}
So, you can use this selector in css as well as in scss file.