Removing input background colour for Chrome autocomplete?

前端 未结 30 1865
失恋的感觉
失恋的感觉 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:27

    None of the solutions worked for me, the inset shadow won't work for me because the inputs have a translucent background overlaid over the page background.

    So I asked myself, "How does Chrome determine what should be autofilled on a given page?"

    "Does it look for input ids, input names? Form ids? Form action?"

    Through my experimentation with the username and the password inputs, there were only two ways I found that would cause Chrome to not be able to find the fields that should be autofilled:

    1) Put the password input ahead of the text input. 2) Give them the same name and id ... or no name and id at all.

    After the page loads, with javascript you can either dynamically change the order of the inputs on the page, or dynamically give them their name and id ...

    And Chrome doesn't know what hit it ... autocomplete is broken!

    Crazy hack, I know. But it's working for me.

    Chrome 34.0.1847.116, OSX 10.7.5

    0 讨论(0)
  • 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;
    }
    <input type="text" name="email" />
    <input type="text" name="email" class="no-autofill-bkg" />

    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.

    0 讨论(0)
  • 2020-11-22 04:29

    After 2 hours of searching it seems google still overrides the yellow color somehow but i for the fix for it. That's right. it will work for hover, focus etc as well. all you have to do is add !important to it.

     input:-webkit-autofill,
     input:-webkit-autofill:hover,
     input:-webkit-autofill:focus,
     input:-webkit-autofill:active {
     -webkit-box-shadow: 0 0 0px 1000px white inset !important;
      }
    

    this will completely remove yellow from input fields

    0 讨论(0)
  • 2020-11-22 04:29

    i use this. work for me. remove yellow background of field.

    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    input:-webkit-autofill:active,
    input:-webkit-autofill:valid,
    select:-webkit-autofill,
    select:-webkit-autofill:hover,
    select:-webkit-autofill:focus
    {
        -webkit-transition-delay: 99999s;
        -webkit-text-fill-color:#D7D8CE;
    }
    
    0 讨论(0)
  • 2020-11-22 04:30

    This is my solution, I used transition and transition delay therefore I can have a transparent background on my input fields.

    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    input:-webkit-autofill:active {
        -webkit-transition: "color 9999s ease-out, background-color 9999s ease-out";
        -webkit-transition-delay: 9999s;
    }
    
    0 讨论(0)
  • 2020-11-22 04:30

    Unfortunately strictly none of the above solutions worked for me in 2016 (a couple years after the question)

    So here's the aggressive solution I use:

    function remake(e){
        var val = e.value;
        var id = e.id;
        e.outerHTML = e.outerHTML;
        document.getElementById(id).value = val;
        return true;
    }
    
    <input id=MustHaveAnId type=text name=email autocomplete=on onblur="remake(this)">
    

    Basically, it deletes the tag while saving the value, and recreates it, then puts back the value.

    0 讨论(0)
提交回复
热议问题