:not(:empty) CSS selector is not working?

后端 未结 11 1071
我寻月下人不归
我寻月下人不归 2020-11-28 06:22

I\'m having a heck of a time with this particular CSS selector which does not want to work when I add :not(:empty) to it. It seems to work fine with any combina

11条回答
  •  离开以前
    2020-11-28 06:32

    You could try using :placeholder-shown...

    input {
      padding: 10px 15px;
      font-size: 16px;
      border-radius: 5px;
      border: 2px solid lightblue;
      outline: 0;
      font-weight:bold;
      transition: border-color 200ms;
      font-family: sans-serif;
    }
    
    .validation {
      opacity: 0;
      font-size: 12px;
      font-family: sans-serif;
      color: crimson;
      transition: opacity;
    }
    
    input:required:valid {
      border-color: forestgreen;
    }
    
    input:required:invalid:not(:placeholder-shown) {
      border-color: crimson;
    }
    
    input:required:invalid:not(:placeholder-shown) + .validation {
      opacity: 1;
    }
    
      
    
    
    Not valid

    no great support though... caniuse

提交回复
热议问题