How do you make an input field opacity not effect the text color inside it?

Jordan Simon picture Jordan Simon · Sep 10, 2013 · Viewed 31.5k times · Source

I have a dark/black background image and a white input field. I gave the input field an opacity of 50% and I want the text/value to be solid white(#fff). BUT when I apply the opacity it effects both the background of the input element and the text. How to I only change the background of the input field?

Answer

Beniamin Szabo picture Beniamin Szabo · Sep 10, 2013

For that you could use background-color: rgba(0, 0, 0, 0.5). The first three numbers are the background color in rgb (red, green, blue) format and the fourth number is the opacity level on a scale from 0 to 1.