Removing input background colour for Chrome autocomplete?

前端 未结 30 2406
失恋的感觉
失恋的感觉 2020-11-22 04:02

On a form I\'m working on, Chrome is auto-filling the email and password fields. This is fine, however, Chrome changes the background colour to a pale yellow colour.

30条回答
  •  不知归路
    2020-11-22 04:29

    To have a transparent background while not using a time delay (especially needed in modern web applications where people can stop using it for a while and want a predictable behavior of the interface), use this:

    input:-webkit-autofill { 
        -webkit-background-clip: text;
    }
    

    body {
      background: lightblue;
    }
    
    input {
      background: transparent;
    }
    
    input.no-autofill-bkg:-webkit-autofill {
      -webkit-background-clip: text;
    }
    
    

    Working on: Chrome 83 / 84.0.4147.89, Edge 84.0.522.44

    If you decide to re-post my solution, I only ask that you include my name or link to this.

提交回复
热议问题