26

i wanted to set the background color to transparent to my input when the browser autocomplete my form, currently looks like the image added, anyone know how to accomplish this?

I've tried this but it set to white and the borders are style with the yellow default, i want the color for the text to be white too.

input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px white inset;
}

This is how it looks:

enter image description here

Thanks in advance :)

martinezjc
  • 3,415
  • 3
  • 21
  • 29
  • You want `white` background not `transparent`? – Fares M. Apr 11 '15 at 17:16
  • yes transparent but this is the example i found, so i need it transparent with white text in the input – martinezjc Apr 11 '15 at 17:17
  • 1
    `-webkit-text-fill-color`? and `background-color`? Possible duplicate: http://stackoverflow.com/questions/2781549/removing-input-background-colour-for-chrome-autocomplete – Downgoat Apr 11 '15 at 17:20

4 Answers4

71

Finally i get the result with this piece of code:

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    transition: background-color 5000s ease-in-out 0s;
    -webkit-text-fill-color: #fff !important;
}
martinezjc
  • 3,415
  • 3
  • 21
  • 29
30

use this to save your time

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
   -webkit-transition-delay: 9999s;
   transition-delay: 9999s;
}
wahmal
  • 809
  • 11
  • 27
21

thanks martinezjc for the idea, but if we leave page opened for some time we will notice backround change

we can eliminate transition using css animation and forwards fill mode to make background color permanent

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-animation: autofill 0s forwards;
    animation: autofill 0s forwards;
}

@keyframes autofill {
    100% {
        background: transparent;
        color: inherit;
    }
}

@-webkit-keyframes autofill {
    100% {
        background: transparent;
        color: inherit;
    }
}

just replace transparent with your color

Community
  • 1
  • 1
ForceUser
  • 1,129
  • 1
  • 15
  • 23
  • 2
    Nice i like this. It's amazing all the crap we have to go through just to change a color. – Eric Guan Nov 02 '17 at 21:16
  • This solution is more stable. 1. This won't change color after a time 2. If you try to fill an address with name, address, phone etc then this solutions ROCKS (First solution only prevent color change in changed field). – CaptainZero May 19 '19 at 10:36
  • perfect! Thanks. – Vishal Mar 17 '20 at 11:37
  • 1
    @CaptainAdmin Note that this solution does not work at all in desktop Safari. – Fer Apr 05 '20 at 20:50
5

After hours of searching, here is the best code that works jquery and javascript meaning it makes the field transparent as requested

     input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-animation: autofill 0s forwards;
    animation: autofill 0s forwards;
}

@keyframes autofill {
    100% {
        background: transparent;
        color: inherit;
    }
}

@-webkit-keyframes autofill {
    100% {
        background: transparent;
        color: inherit;
    }
}

Perfect good