Removing input background colour for Chrome autocomplete?

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

    This worked for me:

    padding: 5px;
    background-clip: content-box;
    
    0 讨论(0)
  • 2020-11-22 04:15

    A possible workaround for the moment is to set a "strong" inside shadow:

    input:-webkit-autofill {
        -webkit-box-shadow:0 0 0 50px white inset; /* Change the color to your own background color */
        -webkit-text-fill-color: #333;
    }
    
    input:-webkit-autofill:focus {
        -webkit-box-shadow: /*your box-shadow*/,0 0 0 50px white inset;
        -webkit-text-fill-color: #333;
    }  
    
    0 讨论(0)
  • 2020-11-22 04:16

    This works fine, You can change input box styles as well as text styles inside input box :

    Here you can use any color e.g. white, #DDD, rgba(102, 163, 177, 0.45).

    But transparent won't work here.

    /* Change the white to any color ;) */
    input:-webkit-autofill,
    input:-webkit-autofill:hover, 
    input:-webkit-autofill:focus, 
    input:-webkit-autofill:active  {
        -webkit-box-shadow: 0 0 0 30px white inset !important;
    }
    

    Additionally, you can use this to change the text color:

    /*Change text in autofill textbox*/
    input:-webkit-autofill {
        -webkit-text-fill-color: yellow !important;
    }
    

    Advice: Don't use an excessive blur radius in the hundreds or thousands. This has no benefit and might put processor load on weaker mobile devices. (Also true for actual, outside shadows). For a normal input box of 20px height, 30px ‘blur radius’ will perfectly cover it.

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

    This will work for input, textarea and select in normal, hover, focus and active states.

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

    Here is SCSS version of the above solution for those who are working with SASS/SCSS.

    input:-webkit-autofill,
    textarea:-webkit-autofill,
    select:-webkit-autofill
    {
        &, &:hover, &:focus, &:active
        {
            -webkit-box-shadow: 0 0 0px 1000px white inset !important;
        }
    }
    
    0 讨论(0)
  • 2020-11-22 04:17

    For those who are using Compass:

    @each $prefix in -webkit, -moz {
        @include with-prefix($prefix) {
            @each $element in input, textarea, select {
                #{$element}:#{$prefix}-autofill {
                    @include single-box-shadow(0, 0, 0, 1000px, $white, inset);
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-11-22 04:18

    Try this: Same as @Nathan-white answer above with minor tweaks.

    /* For removing autocomplete highlight color in chrome (note: use this at bottom of your css file). */
    
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    input:-webkit-autofill:active {
        transition: all 5000s ease-in-out 0s;
        transition-property: background-color, color;
    }
    
    0 讨论(0)
提交回复
热议问题