CSS:不是父运算符

时间:2019-07-30 02:34:04

标签: css sass

<input type="checkbox" >

<aup-switch>
    <input type="checkbox" >
</aup-switch>

我为input[type="checkbox"]使用css样式,但是我不希望将其应用于aup-switch内的输入组件。 我尝试使用CSS的not选择器,但不起作用。

input[type="checkbox"]:not(aup-switch input[type="checkbox"]) {
    &+label {
        position: relative;
        cursor: pointer;
        padding: 0;
    }
}

2 个答案:

答案 0 :(得分:1)

考虑代码:

// scss:
aup-switch {
  input {
   // other styles
   }
}

input {
 position: relative;
 cursor: pointer;
 padding: 0;
}


// compiled

aup-swich input { // other styles }
input { position: relative; cursor: pointer; padding: 0;}

答案 1 :(得分:1)

改为使用*:not(aup-switch) > input[type='checkbox']选择器

*:not(aup-switch) > input[type='checkbox'] {
  -webkit-appearance: unset;
  width: 10px;
  height: 10px;
  background-color: red;
}
Normal checkbox: <input type="checkbox" >

<aup-switch>
    aup-switch checkbox: <input type="checkbox" >
</aup-switch>

相关问题