Removing input background colour for Chrome autocomplete?

前端 未结 30 2384
失恋的感觉
失恋的感觉 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: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;
        }
    }
    

提交回复
热议问题