HTML中可以包含URL吗,html – 匹配包含部分URL和特定类的链接

你可以使用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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值