你可以使用2
CSS attribute selectors
> [class ^ =“flower big”]与^将查找属性名为class且其第一个值以“flower big”为前缀的任何元素.
> [href * =“/ dir / flowers /”]带*,它将查找属性名称为href且其值至少包含一个字符串“/ dir / flowers”作为子字符串的a.
a {
display: block
}
[class^="flower big"][href*="/dir/flowers/"] {
color: red;
}
Will be red because has both classes in order and /dir/flowers/
Will be red because has both classes in order and /dir/flowers/
Will be red because has both classes in order and /dir/flowers/
Won't be red because hasn't classes in order even having the /dir/flowers/
Won't be red because hasn't the /dir/flowers/ even having the correct classes
UPDATE
如果您想要在其中有更多的类或更改这两个类的顺序,那么您需要以不同的方式选择CSS,例如.flower.big或.big.flower.
a {
display: block
}
.big.flower[href*="/dir/flowers/"] {
color: red;
}
Will be red because has both classes in link and /dir/flowers/
Will be red because has both classes in link and /dir/flowers/
Will be red because has both classes in link and /dir/flowers/
Won't be red because hasn't classes in link even having the /dir/flowers/
Won't be red because hasn't the /dir/flowers/ even having the correct classes