可以:not()伪类有多个参数吗?我正在尝试选择除了和之外input的所有元素。typeradiocheckbox很多人已经表明你可以放入多个参数:not,但是使用type似乎无论如何都没有用到我试试。form input:not([type="radio"], [type="checkbox"]) {
/* css here */}有任何想法吗?
3 回答
子衿沉夜
TA贡献1828条经验 获得超3个赞
如果您在项目中使用SASS,我已经构建了这个mixin,使其按照我们想要的方式工作:
@mixin not($ignorList...) {
//if only a single value given
@if (length($ignorList) == 1){
//it is probably a list variable so set ignore list to the variable
$ignorList: nth($ignorList,1);
}
//set up an empty $notOutput variable
$notOutput: '';
//for each item in the list
@each $not in $ignorList {
//generate a :not([ignored_item]) segment for each item in the ignore list and put them back to back
$notOutput: $notOutput + ':not(#{$not})';
}
//output the full :not() rule including all ignored items
&#{$notOutput} {
@content;
}}它可以以两种方式使用:
选项1:列出内联忽略的项目
input {
/*non-ignored styling goes here*/
@include not('[type="radio"]','[type="checkbox"]'){
/*ignored styling goes here*/
}}选项2:首先列出变量中被忽略的项目
$ignoredItems:
'[type="radio"]',
'[type="checkbox"]';input {
/*non-ignored styling goes here*/
@include not($ignoredItems){
/*ignored styling goes here*/
}}两个选项的输出CSS
input {
/*non-ignored styling goes here*/}input:not([type="radio"]):not([type="checkbox"]) {
/*ignored styling goes here*/}
红颜莎娜
TA贡献1842条经验 获得超13个赞
- 3 回答
- 0 关注
- 1039 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消
