亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

可以:not()偽類有多個參數嗎?

可以:not()偽類有多個參數嗎?

當年話下 2019-07-29 11:21:04
可以:not()偽類有多個參數嗎?我正在嘗試選擇除了和之外input的所有元素。typeradiocheckbox很多人已經表明你可以放入多個參數:not,但是使用type似乎無論如何都沒有用到我試試。form input:not([type="radio"], [type="checkbox"]) {   /* css here */}有任何想法嗎?
查看完整描述

3 回答

?
慕斯王

TA貢獻1864條經驗 獲得超2個贊

原因:不只是使用兩個:not

input:not([type="radio"]):not([type="checkbox"])

是的,這是有意的


查看完整回答
反對 回復 2019-07-29
?
子衿沉夜

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*/}


查看完整回答
反對 回復 2019-07-29
?
紅顏莎娜

TA貢獻1842條經驗 獲得超13個贊

從CSS 4開始,:not可以在選擇器中使用多個參數(參見此處)。

在CSS3中,:not selector僅允許1個選擇器作為參數。在第4級選擇器中,它可以將選擇器列表作為參數。

例:

/* In this example, all p elements will be red, except for 
   the first child and the ones with the class special. */p:not(:first-child, .special) {
  color: red;}

不幸的是,瀏覽器支持有限。目前,它只適用于Safari。


查看完整回答
反對 回復 2019-07-29
  • 3 回答
  • 0 關注
  • 1003 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號