31

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 :)

3
  • You want white background not transparent? Commented Apr 11, 2015 at 17:16
  • yes transparent but this is the example i found, so i need it transparent with white text in the input Commented Apr 11, 2015 at 17:17
  • 1
    -webkit-text-fill-color? and background-color? Possible duplicate: stackoverflow.com/questions/2781549/… Commented Apr 11, 2015 at 17:20

5 Answers 5

77

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;
}
Sign up to request clarification or add additional context in comments.

4 Comments

what this: 5000s in background-color
The transition time that will take to remove the background color
no flaws. fine working after tested almost 20 solutions in chrome
it worked for me. And the tip for whom wants to change cursor color is the following: caret-color: #fff;
34

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;
}

4 Comments

This is so simple and works perfect! Best solution IMO.
Not only did this seem to be the only one that worked for me, it's damn short!
Thank you for being such a good person. autofill is just... you know.
This one should be the best answer 👍
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

4 Comments

Nice i like this. It's amazing all the crap we have to go through just to change a color.
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).
@CaptainAdmin Note that this solution does not work at all in desktop Safari.
stopped working on firefox with recent updates ;/
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

Comments

2

GOT THE ANSWER GUYS.. :)

input,
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 50px rgba(255, 255, 255, 0) inset !important;
  background-color: transparent !important;
  background-clip: text;
}

3 Comments

Please try to explain what are the advantages of your solution over the others.
advantage is it works
thanks mate this working worked with in Nextjs 15 after trying all the of the above codes which dint not work for me :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.