需求说明
写CSS的是否,遇到一个需求,需要根据标签的属性(例如属性是否是某个值,是否包含某个属性,是否不包含某个属性)选择出来增加css内容。
实现
input:not([type]), input[type='text'], input[type='password'] {
/* style here */
}
input[type] {
/* 根据input里的是否包含type来选择 */
}
input:not([type]) {
/* 根据input里的属性如果不包含type来选择 */
}
input:not([type='password']) {
/* 根据input里的属性type值不等于text来选择 */
}
input[type='text'] {
/* 根据input里的属性type值等于text来选择 */
}
文章评论